first
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Application\Frontend;
|
||||
|
||||
use Nextend\Framework\Application\AbstractApplicationType;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\SmartSlider3\Application\Frontend\Slider\ControllerPreRenderSlider;
|
||||
use Nextend\SmartSlider3\Application\Frontend\Slider\ControllerSlider;
|
||||
|
||||
class ApplicationTypeFrontend extends AbstractApplicationType {
|
||||
|
||||
protected $key = 'frontend';
|
||||
|
||||
public function __construct($application) {
|
||||
|
||||
ResourceTranslator::createResource('$system$', self::getAssetsPath(), self::getAssetsUri());
|
||||
|
||||
parent::__construct($application);
|
||||
}
|
||||
|
||||
protected function getControllerSlider() {
|
||||
|
||||
return new ControllerSlider($this);
|
||||
}
|
||||
|
||||
protected function getControllerPreRenderSlider() {
|
||||
|
||||
return new ControllerPreRenderSlider($this);
|
||||
}
|
||||
|
||||
protected function getDefaultController($controllerName, $ajax = false) {
|
||||
// TODO: Implement getDefaultController() method.
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Application\Frontend\Slider;
|
||||
|
||||
|
||||
use Nextend\Framework\Asset\Css\Css;
|
||||
use Nextend\Framework\Controller\AbstractController;
|
||||
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
|
||||
use Nextend\Framework\Request\Request;
|
||||
|
||||
class ControllerPreRenderSlider extends AbstractController {
|
||||
|
||||
|
||||
public function actionIframe() {
|
||||
|
||||
$sliderIDorAlias = Request::$GET->getVar('sliderid') !== null ? Request::$GET->getVar('sliderid') : false;
|
||||
|
||||
if (empty($sliderIDorAlias)) {
|
||||
echo 'Slider ID or alias is empty.';
|
||||
} else {
|
||||
Css::addStaticGroup(ResourceTranslator::toPath('$ss3-frontend$/dist/normalize.min.css'), 'normalize');
|
||||
|
||||
|
||||
$view = new ViewIframe($this);
|
||||
|
||||
$view->setSliderIDorAlias($sliderIDorAlias);
|
||||
|
||||
$view->display();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Application\Frontend\Slider;
|
||||
|
||||
|
||||
use Nextend\Framework\Controller\AbstractController;
|
||||
|
||||
class ControllerSlider extends AbstractController {
|
||||
|
||||
public function actionDisplay($sliderID, $usage) {
|
||||
|
||||
$view = new ViewDisplay($this);
|
||||
|
||||
$view->setSliderIDorAlias($sliderID);
|
||||
$view->setUsage($usage);
|
||||
|
||||
$view->display();
|
||||
}
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\SmartSlider3\Application\Frontend\Slider;
|
||||
|
||||
use Nextend\Framework\Asset\AssetManager;
|
||||
use Nextend\Framework\Request\Request;
|
||||
use Nextend\SmartSlider3\Settings;
|
||||
use Nextend\WordPress\OutputBuffer;
|
||||
|
||||
/**
|
||||
* @var ViewIframe $this
|
||||
*/
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="robots" content="noindex">
|
||||
<title>Slider</title>
|
||||
<style>
|
||||
html, body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body * {
|
||||
background-attachment: scroll !important;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
/**
|
||||
* In page builder -> editors, we must force sliders to be visible on every device.
|
||||
*/
|
||||
if (Request::$GET->getInt('iseditor')):
|
||||
?>
|
||||
<script>
|
||||
window.ssOverrideHideOn = {
|
||||
desktopLandscape: 0,
|
||||
desktopPortrait: 0,
|
||||
tabletLandscape: 0,
|
||||
tabletPortrait: 0,
|
||||
mobileLandscape: 0,
|
||||
mobilePortrait: 0
|
||||
};
|
||||
</script>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
$handlers = ob_list_handlers();
|
||||
if (!in_array(OutputBuffer::class . '::outputCallback', $handlers)) {
|
||||
if (class_exists('\\Nextend\\Framework\\Asset\\AssetManager', false)) {
|
||||
|
||||
// PHPCS - Content already escaped
|
||||
echo AssetManager::getCSS(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
|
||||
// PHPCS - Content already escaped
|
||||
echo AssetManager::getJs(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
|
||||
$externals = esc_attr(Settings::get('external-css-files'));
|
||||
if (!empty($externals)) {
|
||||
$externals = explode("\n", $externals);
|
||||
foreach ($externals as $external) {
|
||||
echo "<link rel='stylesheet' href='" . esc_url($external) . "' type='text/css' media='all' />";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
|
||||
// PHPCS - Content already escaped
|
||||
echo $this->getSliderHTML(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
?>
|
||||
<script>
|
||||
|
||||
_N2.r('windowLoad', function () {
|
||||
if (window.n2ss) {
|
||||
var body = document.body,
|
||||
options = {
|
||||
forceFullWidth: 0,
|
||||
fullPage: 0,
|
||||
focusOffsetTop: '',
|
||||
focusOffsetBottom: '',
|
||||
margin: 0,
|
||||
height: 0
|
||||
},
|
||||
setOption = function (name, value) {
|
||||
if (options[name] != value) {
|
||||
options[name] = value;
|
||||
parent.postMessage({
|
||||
key: 'option',
|
||||
name: name,
|
||||
value: value
|
||||
}, "*");
|
||||
}
|
||||
},
|
||||
sliders = [],
|
||||
promise = new Promise(function (resolve) {
|
||||
var checkSliders = function () {
|
||||
if (Object.keys(n2ss.sliders).length) {
|
||||
initSliders();
|
||||
} else {
|
||||
setTimeout(checkSliders, 16);
|
||||
}
|
||||
},
|
||||
initSliders = function () {
|
||||
var promises = [];
|
||||
for (var k in n2ss.sliders) {
|
||||
promises.push(new Promise(function (resolve) {
|
||||
n2ss.ready(k, (function (slider) {
|
||||
sliders.push(slider);
|
||||
resolve();
|
||||
}).bind(this));
|
||||
}));
|
||||
}
|
||||
|
||||
Promise.all(promises).then(resolve);
|
||||
};
|
||||
|
||||
checkSliders();
|
||||
});
|
||||
|
||||
promise.then(function () {
|
||||
|
||||
if (sliders.length === 1) {
|
||||
var sliderElement = sliders[0].sliderElement,
|
||||
marginElement = sliderElement.closest('.n2-ss-margin');
|
||||
|
||||
if (marginElement) {
|
||||
var cs = window.getComputedStyle(marginElement);
|
||||
setOption('margin', [cs.marginTop, cs.marginRight, cs.marginBottom, cs.marginLeft].join(' '));
|
||||
marginElement.style.margin = '0';
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < sliders.length; i++) {
|
||||
var slider = sliders[i];
|
||||
slider.stages.done('ResizeFirst', (function (slider) {
|
||||
if (slider.sliderElement.closest('ss3-force-full-width')) {
|
||||
setOption('forceFullWidth', true);
|
||||
}
|
||||
|
||||
if (slider.responsive.parameters.type === 'fullpage') {
|
||||
setOption('fullPage', true);
|
||||
}
|
||||
|
||||
if (sliders.length === 1) {
|
||||
setOption('focusOffsetTop', slider.responsive.parameters.focus.offsetTop);
|
||||
setOption('focusOffsetBottom', slider.responsive.parameters.focus.offsetBottom);
|
||||
}
|
||||
}).bind(this, slider));
|
||||
|
||||
slider.stages.done('HasDimension', function () {
|
||||
document.querySelectorAll('a:not([target="_parent"]):not([target="_blank"])').forEach(function (a) {
|
||||
a.target = '_parent';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var observer = new ResizeObserver((function (entries) {
|
||||
setOption('height', entries[0].contentRect.height);
|
||||
}).bind(this));
|
||||
|
||||
observer.observe(body);
|
||||
});
|
||||
|
||||
var interval = setInterval(function () {
|
||||
parent.postMessage({key: 'ready'}, "*");
|
||||
}, 40);
|
||||
window.addEventListener("message", function (e) {
|
||||
var data = e.data;
|
||||
switch (data["key"]) {
|
||||
case "ackReady":
|
||||
window.n2Height = data.windowInnerHeight;
|
||||
window.n2OffsetTop = 0;
|
||||
window.n2OffsetBottom = 0;
|
||||
clearInterval(interval);
|
||||
|
||||
document.body.style.setProperty('--target-height', window.n2Height + 'px');
|
||||
break;
|
||||
case 'fullpage':
|
||||
window.n2Height = data.height;
|
||||
window.n2OffsetTop = data.offsetTop;
|
||||
window.n2OffsetBottom = data.offsetBottom;
|
||||
|
||||
document.body.style.setProperty('--target-height', window.n2Height + 'px');
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
n2const.setLocation = function (l) {
|
||||
parent.postMessage({
|
||||
key: 'setLocation',
|
||||
location: l
|
||||
}, "*");
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Application\Frontend\Slider;
|
||||
|
||||
|
||||
use Nextend\Framework\View\AbstractView;
|
||||
use Nextend\SmartSlider3\SliderManager\SliderManager;
|
||||
|
||||
class ViewDisplay extends AbstractView {
|
||||
|
||||
/** @var string|integer */
|
||||
protected $sliderIDorAlias;
|
||||
|
||||
/** @var string */
|
||||
protected $usage;
|
||||
|
||||
public function display() {
|
||||
|
||||
$this->getApplicationType()
|
||||
->enqueueAssets();
|
||||
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
$sliderManager = new SliderManager($this, $this->sliderIDorAlias, false);
|
||||
$sliderManager->setUsage($this->usage);
|
||||
|
||||
// PHPCS - Content already escaped
|
||||
echo $sliderManager->render(true); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|integer
|
||||
*/
|
||||
public function getSliderIDorAlias() {
|
||||
return $this->sliderIDorAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|integer $sliderIDorAlias
|
||||
*/
|
||||
public function setSliderIDorAlias($sliderIDorAlias) {
|
||||
$this->sliderIDorAlias = $sliderIDorAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsage() {
|
||||
return $this->usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $usage
|
||||
*/
|
||||
public function setUsage($usage) {
|
||||
$this->usage = $usage;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\SmartSlider3\Application\Frontend\Slider;
|
||||
|
||||
|
||||
use Nextend\Framework\View\AbstractView;
|
||||
use Nextend\SmartSlider3\SliderManager\SliderManager;
|
||||
|
||||
class ViewIframe extends AbstractView {
|
||||
|
||||
/** @var string|integer */
|
||||
protected $sliderIDorAlias;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $sliderID;
|
||||
|
||||
protected $isGroup = false;
|
||||
|
||||
protected $sliderHTML = '';
|
||||
|
||||
public function display() {
|
||||
|
||||
$this->getApplicationType()
|
||||
->enqueueAssets();
|
||||
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
$sliderManager = new SliderManager($this, $this->sliderIDorAlias, false);
|
||||
$sliderManager->setUsage('iframe');
|
||||
$this->sliderHTML = $sliderManager->render(true);
|
||||
|
||||
$slider = $sliderManager->getSlider();
|
||||
|
||||
if ($slider) {
|
||||
$this->sliderID = $slider->sliderId;
|
||||
$this->isGroup = $slider->isGroup();
|
||||
}
|
||||
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
|
||||
|
||||
// PHPCS - Content already escaped
|
||||
echo $this->render('Iframe'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|integer
|
||||
*/
|
||||
public function getSliderIDorAlias() {
|
||||
return $this->sliderIDorAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|integer $sliderIDorAlias
|
||||
*/
|
||||
public function setSliderIDorAlias($sliderIDorAlias) {
|
||||
$this->sliderIDorAlias = $sliderIDorAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string already escaped
|
||||
*/
|
||||
public function getSliderHTML() {
|
||||
return $this->sliderHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSliderID() {
|
||||
return $this->sliderID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isGroup() {
|
||||
return $this->isGroup;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user