{#
/*
 * Spring Signage Ltd - http://www.springsignage.com
 * Copyright (C) 2015 Spring Signage Ltd
 * (${FILE_NAME})
 */
#}

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

{% block formTitle %}
    {% trans "Add Local Video" %}
{% endblock %}

{% block formButtons %}
    {% trans "Help" %}, XiboHelpRender("{{ help }}")
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Save" %}, $("#localVideoAddForm").submit()
{% endblock %}

{% block formFieldActions %}
    [{
    "field": "useDuration",
    "trigger": "init",
    "value": false,
    "operation": "is:checked",
    "actions": {
    ".duration-fields": { "display": "none" }
    }
    },{
    "field": "useDuration",
    "trigger": "change",
    "value": false,
    "operation": "is:checked",
    "actions": {
    ".duration-fields": { "display": "none" }
    }
    },{
    "field": "useDuration",
    "trigger": "init",
    "value": true,
    "operation": "is:checked",
    "actions": {
    ".duration-fields": { "display": "block" }
    }
    },{
    "field": "useDuration",
    "trigger": "change",
    "value": true,
    "operation": "is:checked",
    "actions": {
    ".duration-fields": { "display": "block" }
    }
    }]
{% endblock %}

{% block formHtml %}
    <div class="row">
        <div class="col-md-12">
            <form id="localVideoAddForm" class="XiboForm form-horizontal" method="post" action="{{ urlFor("module.widget.add", {type: module.widget.type, id: playlist.playlistId}) }}">
                {% set title %}{% trans "Video Path" %}{% endset %}
                {% set helpText %}{% trans "A local file path or URL to the video. This can be a RTSP stream." %}{% endset %}
                {{ forms.input("uri", title, "", helpText, "", "required") }}

                {% set title %}{% trans "Set a duration?" %}{% endset %}
                {% set helpText %}{% trans "Select to provide a specific duration for this Widget" %}{% endset %}
                {{ forms.checkbox("useDuration", title, 0, helpText) }}

                {% set title %}{% trans "Duration" %}{% endset %}
                {% set helpText %}{% trans "The duration in seconds this should be displayed" %}{% endset %}
                {{ forms.number("duration", title, module.getModule().defaultDuration, helpText, "duration-fields", "required") }}

                {% set title %}{% trans "Scale type" %}{% endset %}
                {% set helpText %}{% trans "How should this video be scaled?" %}{% endset %}
                {% set aspect %}{% trans "Aspect" %}{% endset %}
                {% set stretch %}{% trans "Stretch" %}{% endset %}
                {% set options = [
                { scaleTypeId: "aspect", scaleType: aspect },
                { scaleTypeId: "stretch", scaleType: stretch }
                ] %}
                {{ forms.dropdown("scaleTypeId", "single", title, module.getOption("scaleType"), options, "scaleTypeId", "scaleType", helpText) }}

                {% set title %}{% trans "Mute?" %}{% endset %}
                {% set helpText %}{% trans "Should the video be muted?" %}{% endset %}
                {{ forms.checkbox("mute", title, 0, helpText, "mute-fields") }}

                <div class="alert alert-info">
                {% set message %}{% trans "Please note that video scaling and video streaming via RTSP is only supported by Android and webOS players at the current time. The HLS streaming Widget can be used to show compatible video streams on Windows." %}{% endset %}
                {{ forms.message(message) }}
                </div>
            </form>
        </div>
    </div>
{% endblock %}