{#
 # For the full copyright and license information, please view the
 # docs/licenses/LICENSE.txt file that was distributed with this source code.
 #}
<div class="modal fade" id="{{ id }}" tabindex="-1">
    <div class="modal-dialog {% if class is defined %}{{ class }}{% endif %}">
        <div class="modal-content">
            {% block header %}
                {% if title is defined %}
                    <div class="modal-header">
                        <h4 class="modal-title">{{ title }}</h4>
                        {% if closable is defined and closable == true %}<button type="button" class="close" data-dismiss="modal">&times;</button>{% endif %}
                    </div>
                {% endif %}
            {% endblock %}

            {% block content %}
            {% endblock %}

            {% if progressbar is defined %}
                <div class="modal-body" id="{{ progressbar.id }}">
                    <div class="float-right progress-details-text" default-value="{{ progressbar.label|default('Processing...'|trans({}, 'Admin.Global')) }}">
                        {{ progressbar.label|default('Processing...'|trans({}, 'Admin.Global')) }}
                    </div>
                    <div class="progress" style="width: 100%">
                        <div class="progress-bar progress-bar-striped" role="progressbar" style="width: 0%">
                            <span>0 %</span>
                        </div>
                    </div>
                </div>
            {% endif %}

            {% block footer %}
                {% if actions is defined %}
                    <div class="modal-footer">
                        {% if closable is defined and closable == true %}
                            <button type="button" class="btn btn-outline-secondary btn-lg" data-dismiss="modal">
                              {% if closeLabel is defined %}
                                {{ closeLabel }}
                              {% else %}
                                {{ 'Close'|trans({}, 'Admin.Actions') }}
                              {% endif %}
                            </button>
                        {% endif %}
                        {% for action in actions %}
                            {% if action.type is defined and action.type == 'link' %}
                                <a href="{{ action.href|default('#') }}" class="{{ action.class|default('btn') }}">{{ action.label|default('Label is missing') }}</a>
                            {% elseif action.type is defined and action.type == 'button' %}
                                <button type="button" value="{{ action.value|default('') }}" class="{{ action.class|default('btn') }}">
                                    {{ action.label|default('Label is missing') }}
                                </button>
                            {% endif %}
                        {% endfor %}
                    </div>
                {% endif %}
            {% endblock %}
        </div>
    </div>
</div>
<script>
    $(function() {
        var closable = {% if closable is defined and closable == true %}true{% else %}false{% endif %};
        $('#{{ id }}').modal({
            backdrop: (closable ? true : 'static'),
            keyboard: closable,
            closable: closable,
            show: false
        });
    });
</script>
