{#
/*
 * 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 Webpage" %}
{% endblock %}

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

{% block formFieldActions %}
    [{
    "field": "modeId",
    "trigger": "init",
    "value": 1,
    "operation": "equals",
    "actions": {
    ".webpage-widths": { "display": "none" },
    ".webpage-offsets": { "display": "none" }
    }
    },{
    "field": "modeId",
    "trigger": "change",
    "value": 1,
    "operation": "equals",
    "actions": {
    ".webpage-widths": { "display": "none" },
    ".webpage-offsets": { "display": "none" }
    }
    },{
    "field": "modeId",
    "trigger": "init",
    "value": 2,
    "operation": "equals",
    "actions": {
    ".webpage-widths": { "display": "block" },
    ".webpage-offsets": { "display": "block" }
    }
    },{
    "field": "modeId",
    "trigger": "change",
    "value": 2,
    "operation": "equals",
    "actions": {
    ".webpage-widths": { "display": "block" },
    ".webpage-offsets": { "display": "block" }
    }
    },{
    "field": "modeId",
    "trigger": "init",
    "value": 3,
    "operation": "equals",
    "actions": {
    ".webpage-widths": { "display": "block" },
    ".webpage-offsets": { "display": "none" }
    }
    },{
    "field": "modeId",
    "trigger": "change",
    "value": 3,
    "operation": "equals",
    "actions": {
    ".webpage-widths": { "display": "block" },
    ".webpage-offsets": { "display": "none" }
    }
    },{
    "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="webpageAddForm" class="XiboForm form-horizontal" method="post" action="{{ urlFor("module.widget.add", {type: module.widget.type, id: playlist.playlistId}) }}">
                {% set title %}{% trans "Link" %}{% endset %}
                {% set helpText %}{% trans "The Location (URL) of the webpage" %}{% endset %}
                {{ forms.input("uri", title, "", helpText, "", "required") }}

                {% set title %}{% trans "Name" %}{% endset %}
                {% set helpText %}{% trans "An optional name for this widget" %}{% endset %}
                {{ forms.input("name", title, "", helpText) }}

                {% 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 "Options" %}{% endset %}
                {% set helpText %}{% trans "How should this web page be embedded?" %}{% endset %}
                {% set openNatively %}{% trans "Open Natively" %}{% endset %}
                {% set manualPosition %}{% trans "Manual Position" %}{% endset %}
                {% set bestFit %}{% trans "Best Fit" %}{% endset %}
                {% set options = [
                { modeid: 1, mode: openNatively },
                { modeid: 2, mode: manualPosition },
                { modeid: 3, mode: bestFit }
                ] %}
                {{ forms.dropdown("modeId", "single", title, "", options, "modeid", "mode", helpText) }}

                {% set title %}{% trans "Page Width" %}{% endset %}
                {% set helpText %}{% trans "The width of the page. Leave empty to use the region width." %}{% endset %}
                {{ forms.number("pageWidth", title, pageWidth, helpText, "webpage-widths") }}

                {% set title %}{% trans "Page Height" %}{% endset %}
                {% set helpText %}{% trans "The height of the page. Leave empty to use the region height." %}{% endset %}
                {{ forms.number("pageHeight", title, pageHeight, helpText, "webpage-widths") }}

                {% set title %}{% trans "Offset Top" %}{% endset %}
                {% set helpText %}{% trans "The starting point from the top in pixels" %}{% endset %}
                {{ forms.number("offsetTop", title, offsetTop, helpText, "webpage-offsets") }}

                {% set title %}{% trans "Offset Left" %}{% endset %}
                {% set helpText %}{% trans "The starting point from the left in pixels" %}{% endset %}
                {{ forms.number("offsetLeft", title, offsetLeft, helpText, "webpage-offsets") }}

                {% set title %}{% trans "Scale Percentage" %}{% endset %}
                {% set helpText %}{% trans "The Percentage to Scale this Webpage (0 - 100)" %}{% endset %}
                {{ forms.number("scaling", title, scaling, helpText, "webpage-offsets") }}

                {% set title %}{% trans "Background transparent?" %}{% endset %}
                {% set helpText %}{% trans "Should the HTML be shown with a transparent background. Not currently available on the Windows Display Client." %}{% endset %}
                {{ forms.checkbox("transparency", title, transparency, helpText) }}

            </form>
        </div>
    </div>
{% endblock %}