{% extends '@nucleus/partials/particle.html.twig' %}

{% set attr_extra = '' %}
{% if particle.extra %}
    {% for attributes in particle.extra %}
        {% for key, value in attributes %}
            {% set attr_extra = attr_extra ~ ' ' ~ key|e ~ '="' ~ value|e('html_attr') ~ '"' %}
        {% endfor %}
    {% endfor %}
{% endif %}

{% set attr_extra_left = '' %}
{% if particle.extra_left %}
    {% for attributes in particle.extra_left %}
        {% for key, value in attributes %}
            {% set attr_extra_left = attr_extra_left ~ ' ' ~ key|e ~ '="' ~ value|e('html_attr') ~ '"' %}
        {% endfor %}
    {% endfor %}
{% endif %}

{% set attr_extra_right = '' %}
{% if particle.extra_right %}
    {% for attributes in particle.extra_right %}
        {% for key, value in attributes %}
            {% set attr_extra_right = attr_extra_right ~ ' ' ~ key|e ~ '="' ~ value|e('html_attr') ~ '"' %}
        {% endfor %}
    {% endfor %}
{% endif %}

{% set textcontent %}
    {% if particle.title %}
        <h3 class="g-memories-title">
            {{- particle.title|raw -}}
        </h3>
    {% endif %}

    {% if particle.description %}
        <p class="g-memories-desc">
            {{- particle.description|raw -}}
        </p>
    {% endif %}

    {% if particle.link %}
        <a class="button g-memories-link" href="{{ particle.link|e }}" target="{{ particle.target|default('_blank')|e }}">
            {%- if particle.buttonicon -%}
                <i class="{{ particle.buttonicon|e }}"></i>
            {%- endif -%}
            {{- particle.buttontext|raw -}}
        </a>
    {% endif %}
{% endset %}

{% set galleryid = random() %}

{% set imagecontent %}
    <div class="g-memories-images">
        {% if particle.image1 %}
            {% if particle.parallax|default('enable') == 'enable' %}
                <div class="g-memories-parallax" data-uk-parallax="{y: '-50,50', media: 767}">
            {% endif %}
                <div class="g-memories-image-container g-memories-image1">
                    {% if particle.lightbox|default('enable') == 'enable' %}
                        <a class="uk-overlay uk-overlay-hover" href="{{ url(particle.image1, false, 0) }}" data-uk-lightbox="{group:'{{ galleryid }}'}">
                            <span class="uk-overlay-panel uk-overlay-background uk-overlay-icon uk-overlay-fade"></span>
                    {% endif %}
                        <img alt="{{ particle.alt|e }}" src="{{ url(particle.image1) }}" {{ particle.image1|imagesize|raw }}>
                    {% if particle.lightbox|default('enable') == 'enable' %}
                        </a>
                    {% endif %}
                </div>
            {% if particle.parallax|default('enable') == 'enable' %}
                </div>
            {% endif %}
        {% endif %}

        {% if particle.image2 %}
            {% if particle.parallax|default('enable') == 'enable' %}
                <div class="g-memories-parallax" data-uk-parallax="{x: '50, -50', media: 767}">
            {% endif %}
                <div class="g-memories-image-container g-memories-image2">
                    {% if particle.lightbox|default('enable') == 'enable' %}
                        <a class="uk-overlay uk-overlay-hover" href="{{ url(particle.image2, false, 0) }}" data-uk-lightbox="{group:'{{ galleryid }}'}">
                            <span class="uk-overlay-panel uk-overlay-background uk-overlay-icon uk-overlay-fade"></span>
                    {% endif %}
                        <img alt="{{ particle.alt|e }}" src="{{ url(particle.image2) }}" {{ particle.image2|imagesize|raw }}>
                    {% if particle.lightbox|default('enable') == 'enable' %}
                        </a>
                    {% endif %}
                </div>
            {% if particle.parallax|default('enable') == 'enable' %}
                </div>
            {% endif %}
        {% endif %}

        {% if particle.image3 %}
            {% if particle.parallax|default('enable') == 'enable' %}
                <div class="g-memories-parallax" data-uk-parallax="{x: '-50, 50', media: 767}">
            {% endif %}
                <div class="g-memories-image-container g-memories-image3">
                    {% if particle.lightbox|default('enable') == 'enable' %}
                        <a class="uk-overlay uk-overlay-hover" href="{{ url(particle.image3, false, 0) }}" data-uk-lightbox="{group:'{{ galleryid }}'}">
                            <span class="uk-overlay-panel uk-overlay-background uk-overlay-icon uk-overlay-fade"></span>
                    {% endif %}
                        <img alt="{{ particle.alt|e }}" src="{{ url(particle.image3) }}" {{ particle.image3|imagesize|raw }}>
                    {% if particle.lightbox|default('enable') == 'enable' %}
                        </a>
                    {% endif %}
                </div>
            {% if particle.parallax|default('enable') == 'enable' %}
                </div>
            {% endif %}
        {% endif %}

        {% if particle.image4 %}
            {% if particle.parallax|default('enable') == 'enable' %}
                <div class="g-memories-parallax" data-uk-parallax="{y: '50,-50', media: 767}">
            {% endif %}
                <div class="g-memories-image-container g-memories-image4">
                    {% if particle.lightbox|default('enable') == 'enable' %}
                        <a class="uk-overlay uk-overlay-hover" href="{{ url(particle.image4, false, 0) }}" data-uk-lightbox="{group:'{{ galleryid }}'}">
                            <span class="uk-overlay-panel uk-overlay-background uk-overlay-icon uk-overlay-fade"></span>
                    {% endif %}
                        <img alt="{{ particle.alt|e }}" src="{{ url(particle.image4) }}" {{ particle.image4|imagesize|raw }}>
                    {% if particle.lightbox|default('enable') == 'enable' %}
                        </a>
                    {% endif %}
                </div>
            {% if particle.parallax|default('enable') == 'enable' %}
                </div>
            {% endif %}
        {% endif %}
    </div>
{% endset %}

{% block particle %}
    <div class="g-memories{% if particle.css.class %} {{ particle.css.class|e }}{% endif %}" {% if particle.extra %}{{ attr_extra|raw }}{% endif %}>
        <div class="g-grid">
            <div class="g-block g-memories-left{% if particle.css.left %} {{ particle.css.left|e }}{% endif %}{% if particle.layout|default('right')|e == 'left' %} image-block{% endif %}" {% if particle.extra_left %}{{ attr_extra_left|raw }}{% endif %}>
                <div class="g-content">
                    {% if particle.layout|default('right')|e == 'right' %}{{ textcontent }}{% endif %}
                    {% if particle.layout|default('right')|e == 'left' %}{{ imagecontent }}{% endif %}
                </div>
            </div>

            <div class="g-block g-memories-right{% if particle.css.right %} {{ particle.css.right|e }}{% endif %}{% if particle.layout|default('right')|e == 'right' %} image-block{% endif %}" {% if particle.extra_right %}{{ attr_extra_right|raw }}{% endif %}>
                <div class="g-content">
                    {% if particle.layout|default('right')|e == 'right' %}{{ imagecontent }}{% endif %}
                    {% if particle.layout|default('right')|e == 'left' %}{{ textcontent }}{% endif %}
                </div>
            </div>
        </div>
    </div>
{% endblock %}