{#
/**
 * Copyright (C) 2020 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - http://www.xibo.org.uk
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
#}

{% extends "form-base.twig" %}
{% import "forms.twig" as forms %}

{% block formTitle %}
    {% trans "Region Options" %}
{% endblock %}

{% block formHtml %}
    <div class="row">

        <ul class="nav nav-tabs" role="tablist">
            <li class="nav-item"><a class="nav-link active" href="#generalTab" role="tab" data-toggle="tab"><span>{% trans "General" %}</span></a></li>
            <li class="nav-item"><a class="nav-link" href="#positioningTab" role="tab" data-toggle="tab"><span>{% trans "Positioning" %}</span></a></li>
            <li class="nav-item"><a class="nav-link" href="#transitionTab" role="tab" data-toggle="tab"><span>{% trans "Transition" %}</span></a></li>
        </ul>

        <div class="col-md-12">
            <form id="regionEditForm" class="XiboForm form-horizontal" method="put" action="{{ url_for("region.edit", {id: region.regionId}) }}">
                <div class="tab-content">
                    <div class="tab-pane active" id="generalTab">
                        {% set title %}{% trans "Name" %}{% endset %}
                        {% set helpText %}{% trans "Name of the Region" %}{% endset %}
                        {{ forms.input("name", title, region.name, helpText) }}

                        {% set title %}{% trans "Loop?" %}{% endset %}
                        {% set helpText %}{% trans "If there is only one item in this region should it loop?" %}{% endset %}
                        {{ forms.checkbox("loop", title, region.getOptionValue("loop", 0), helpText) }}

                        {% set message = "When should the Region Loop be enabled?"|trans %}
                        {{ forms.message(message, 'alert-info') }}
                        {% set message2 = "* If your Region contains more than one Widget, Loop should not be enabled."|trans %}
                        {{ forms.message(message2, 'alert-info') }}
                        {% set message3 = "* If your Region contains one Widget, and that Widget is a 'fixed' item (eg Text), Loop should not be enabled."|trans %}
                        {{ forms.message(message3, 'alert-info') }}
                        {% set message4 = "* If your Region contains one Widget, and that Widget needs to update periodically (eg RSS Ticker Widget), Loop can be enabled ONLY if the Widget needs to update MORE frequently than the duration of the overall Layout."|trans %}
                        {{ forms.message(message4, 'alert-info') }}

                    </div>

                    <div class="tab-pane" id="positioningTab">
                        {% set title %}{% trans "Top" %}{% endset %}
                        {% set helpText %}{% trans "Offset from the Top Corner" %}{% endset %}
                        {{ forms.number("top", title, region.top, helpText) }}

                        {% set title %}{% trans "Left" %}{% endset %}
                        {% set helpText %}{% trans "Offset from the Left Corner" %}{% endset %}
                        {{ forms.number("left", title, region.left, helpText) }}

                        {% set title %}{% trans "Width" %}{% endset %}
                        {% set helpText %}{% trans "Width of the Region" %}{% endset %}
                        {{ forms.number("width", title, region.width, helpText) }}

                        {% set title %}{% trans "Height" %}{% endset %}
                        {% set helpText %}{% trans "Height of the Region" %}{% endset %}
                        {{ forms.number("height", title, region.height, helpText) }}

                        {% set title %}{% trans "Layer" %}{% endset %}
                        {% set helpText %}{% trans "The layering order of this region (z-index). Advanced use only." %}{% endset %}
                        {{ forms.number("zIndex", title, region.zIndex, helpText) }}

                        {% set title %}{% trans "Make this Region full screen, dimensions will be set to [width] by [height]." %}{% endset %}
                        <div>
                            <button type="button" id="setFullScreenButton" class="btn btn-block btn-outline-primary">{{title}}</button>
                        </div>
                    </div>

                    <div class="tab-pane" id="transitionTab">
                        {% set title %}{% trans "Exit Transition" %}{% endset %}
                        {% set helpText %}{% trans "What transition should be applied when this region is finished?" %}{% endset %}
                        {{ forms.dropdown("transitionType", "single", title, region.getOptionValue("transitionType"), [{code: null, transition: ""}]|merge(transitions.out), "code", "transition", helpText) }}

                        {{ forms.number("transitionDuration", "Duration", region.getOptionValue("transitionDuration"), "The duration for this transition, in milliseconds.", "transition-group") }}

                        {% set title %}{% trans "Direction" %}{% endset %}
                        {% set helpText %}{% trans "The direction for this transition. Only appropriate for transitions that move, such as Fly." %}{% endset %}
                        {{ forms.dropdown("transitionDirection", "single", title, region.getOptionValue("transitionDirection"), transitions.compassPoints, "id", "name", helpText, "transition-group transition-direction") }}
                    </div>
                </div>
            </form>
        </div>
    </div>
{% endblock %}