namespace Cube\Elementor\Widgets;
+use Elementor\Repeater;
use Elementor\Utils;
use Elementor\Controls_Manager;
]
);
- $this->add_control(
- 'title',
- [
- 'label' => __( 'Title', 'elementor' ),
- 'type' => Controls_Manager::TEXTAREA,
- 'placeholder' => __( 'Enter your title', 'elementor' ),
- 'default' => '',
- ]
- );
-
- $this->add_control(
- 'body',
- [
- 'label' => __('Body', 'cube'),
- 'type' => Controls_Manager::TEXTAREA,
- 'default' => '',
- ]
- );
-
$this->add_control(
'images_desktop',
[
'show_external' => true
]
);
+
+ $repeater = new Repeater();
+
+ $repeater->add_control(
+ 'title',
+ [
+ 'label' => __( 'Title', 'elementor' ),
+ 'type' => Controls_Manager::TEXTAREA,
+ 'placeholder' => __( 'Enter your title', 'elementor' ),
+ 'default' => '',
+ ]
+ );
+
+ $repeater->add_control(
+ 'body',
+ [
+ 'label' => __('Body', 'cube'),
+ 'type' => Controls_Manager::WYSIWYG,
+ 'default' => '',
+ ]
+ );
+
+ $this->add_control(
+ 'items',
+ [
+ 'label' => __('Items', 'cube'),
+ 'type' => Controls_Manager::REPEATER,
+ 'fields' => $repeater->get_controls(),
+ 'title_field' => '{{{ title }}}',
+ ]
+ );
$this->end_controls_section();
protected function render() {
$id = 'header_slideshow_' . $this->get_id();
- $title = $this->get_settings('title');
- $body = $this->get_settings('body');
+ $items = $this->get_settings('items');
$images_desktop = $this->get_settings('images_desktop');
$images_mobile = $this->get_settings('images_mobile');
$cta_text = $this->get_settings('cta_text');
<div class="header-slideshow elementor" id="<?= $id ?>">
<?php foreach($images_desktop as $index => $desktop_image): ?>
- <div class="header-slideshow-image<?= $index === 0 ? ' showing' : '' ?>">
+ <div class="header-slideshow-image<?= $index === 0 ? ' showing' : '' ?> header-slideshow-all">
<?php if (isset($images_mobile[$index]['id'])): ?>
<div class="header-slideshow-image-mobile"
After recent updates, the parent must also have the class "elementor" for animations to work.
*/
?>
-
- <?php if (!empty($title) || !empty($body)): ?>
-
- <h1 class="header-slideshow-content elementor-element elementor-invisible"
- data-settings='{"animation":"fadeInRight","animation_delay":0}'
- data-element_type="section">
- <div class="header-slideshow-title"><?= $title ?></div>
- <span class="header-slideshow-body"><?= $body ?></span>
-
- <?php if (!empty($cta_text) || !empty($cta_text_2)) { ?>
- <div class="header-slideshow-buttons flex items-center">
- <?php if (!empty($cta_text)) { ?>
- <a href="<?php echo $cta_link; ?>" class="btn btn-no-hover flex items-center text-sm">
- <?php if (!empty($cta_icon)){ ?>
- <img src="<?php echo $cta_icon ?>" class="mr-2">
- <?php } ?>
- <?php echo $cta_text; ?>
- </a>
- <?php } if (!empty($cta_text_2)) { ?>
- <a href="<?php echo $cta_link_2; ?>" class="btn btn-no-hover flex items-center text-sm">
- <?php if (!empty($cta_2_icon)){ ?>
- <img src="<?php echo $cta_2_icon ?>" class="mr-2">
- <?php } ?>
- <?php echo $cta_text_2; ?>
- </a>
- <?php } ?>
- </div>
- <?php } ?>
- </h1>
-
- <?php endif; ?>
+ <?php
+ foreach ($images_desktop as $index => $item):
+ $items[$index]['title'] = $items[$index]['title'] ?? '';
+ $items[$index]['body'] = $items[$index]['body'] ?? '';
+ ?>
+
+ <h1 class="header-slideshow-content elementor-element elementor-invisible <?= $index === 0 ? ' showing' : '' ?>"
+ data-settings='{"animation":"fadeInRight","animation_delay":0}'
+ data-element_type="section">
+ <div class="header-slideshow-title"><?= $items[$index]['title'] ?></div>
+ <div class="header-slideshow-body"><?= $items[$index]['body'] ?></div>
+
+ <?php if (!empty($cta_text) || !empty($cta_text_2)) { ?>
+ <div class="header-slideshow-buttons flex items-center">
+ <?php if (!empty($cta_text)) { ?>
+ <a href="<?php echo $cta_link; ?>" class="btn btn-no-hover flex items-center text-sm">
+ <?php if (!empty($cta_icon)){ ?>
+ <img src="<?php echo $cta_icon ?>" class="mr-2">
+ <?php } ?>
+ <?php echo $cta_text; ?>
+ </a>
+ <?php } if (!empty($cta_text_2)) { ?>
+ <a href="<?php echo $cta_link_2; ?>" class="btn btn-no-hover flex items-center text-sm">
+ <?php if (!empty($cta_2_icon)){ ?>
+ <img src="<?php echo $cta_2_icon ?>" class="mr-2">
+ <?php } ?>
+ <?php echo $cta_text_2; ?>
+ </a>
+ <?php } ?>
+ </div>
+ <?php } ?>
+ </h1>
+
+ <?php
+ endforeach;
+ ?>
</div>
</div>
}
.header-logo {
- width: 85%;
+ width: 100%;
}
.header-logo-container {
- max-width: 45%;
+ max-width: 255px;
}
@media only screen and (max-width: 1199px) {
-moz-osx-font-smoothing: grayscale;
background: rgba(3,18,54,0.84);
text-transform: none;
- padding: 3.75em 2em 0.75em 3.9em;
+ padding: 3.75em 2em 0.75em 2.5em;
margin: 0 !important;
- z-index: 10;
position: absolute;
bottom: 9.2vw;
left: 0;
width: 50%;
height: 100%;
font-size: 2.1875vw;
+ z-index: 1;
}
@media only screen and (min-width: 1920px) {
}
}
+.header-slideshow .header-slideshow-content.showing {
+ z-index: 10;
+}
+
.header-slideshow .header-slideshow-content:before {
content: none;
}
.header-slideshow-title {
display: block;
- font-size: 1em;
+ font-size: 1.333em;
margin-bottom: 1em;
position: relative;
}
.header-slideshow-title:before {
- content: '';
top: 0.5em;
left: -17px;
width: 1.2em;
}
.header-slideshow-body {
- font-size: 1.333em;
+ font-size: 26px;
+ font-size: 1.181818181818182rem;
white-space: pre-line;
+ font-family: Roboto Condensed, sans-serif;
+ font-weight: light;
+}
+
+.header-slideshow-body li {
+ list-style-type: none;
+ padding-bottom: 2rem;
+ position: relative;
+ padding-left: 38px;
+}
+
+.header-slideshow-body li:before {
+ content: "";
+ width: 20px;
+ height: 20px;
+ display: inline-flex;
+ background: #ffbf29;
+ left: 0;
+ position: absolute;
+ border-radius: 50px;
}
-.header-slideshow-buttons {
+-buttons {
margin-top: 57px;
gap: 17px;
flex-wrap: wrap;
}
@media only screen and (max-width: 999px) {
- .header-slideshow-buttons {
+ -buttons {
margin-top: 20px;
gap: 9px;
flex-wrap: nowrap;
}
@media only screen and (max-width: 599px) {
- .header-slideshow-buttons {
+ -buttons {
flex-wrap: wrap;
}
}
-.header-slideshow-buttons a,
-.header-slideshow-buttons .btn {
+-buttons a,
+-buttons .btn {
padding: 1em 1.8em;
}
@media only screen and (max-width: 999px) {
- .header-slideshow-buttons a,
- .header-slideshow-buttons .btn {
+ -buttons a,
+ -buttons .btn {
font-size: 0.9rem;
}
}
-.header-slideshow-buttons a img,
-.header-slideshow-buttons .btn img {
+-buttons a img,
+-buttons .btn img {
margin-right: 0.9rem;
}
@media only screen and (max-width: 999px) {
- .header-slideshow-buttons a img,
- .header-slideshow-buttons .btn img {
+ -buttons a img,
+ -buttons .btn img {
width: 20px;
}
}
// Inspired by: https://www.sitepoint.com/make-a-simple-javascript-slideshow-without-jquery/
const slides = $scope.find('.header-slideshow-image');
+ const slidesText = $scope.find('.header-slideshow-content');
const slideInterval = setInterval(nextSlide, 4000);
let currentSlide = 0;
$(document).on('click', '.header-slideshow-dots li', function() {
clearInterval(slideInterval); // Stop autoplay
- showSlide($(this).data('slide'));
+ let index = $(this).data('slide')
+ showSlide(index);
});
}
function showSlide(index) {
+ removeBySlide(slides)
+ removeBySlide(slidesText)
+ currentSlide = (index + slides.length) % slides.length;
+ addBySlides(slides)
+ addBySlides(slidesText)
+ }
+
+ function removeBySlide(slides) {
$(slides[currentSlide]).removeClass('showing');
$scope.find(`[data-slide="${currentSlide}"]`).removeClass('active');
- currentSlide = (index + slides.length) % slides.length;
+ }
+
+ function addBySlides(slides) {
$(slides[currentSlide]).addClass('showing');
$scope.find(`[data-slide="${currentSlide}"]`).addClass('active');
}