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

{% block formButtons %}
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Save" %}, $("#textAddForm").submit()
{% endblock %}

{% block callBack %}text_callback{% endblock %}

{% block formFieldActions %}
    [{
    "field": "effect",
    "trigger": "init",
    "value": "",
    "operation": "equals",
    "actions": {
    ".effect-controls": { "display": "none" }
    }
    },{
    "field": "effect",
    "trigger": "change",
    "value": "",
    "operation": "equals",
    "actions": {
    ".effect-controls": { "display": "none" }
    }
    },{
    "field": "effect",
    "trigger": "init",
    "value": "",
    "operation": "not",
    "actions": {
    ".effect-controls": { "display": "block" }
    }
    },{
    "field": "effect",
    "trigger": "change",
    "value": "",
    "operation": "not",
    "actions": {
    ".effect-controls": { "display": "block" }
    }
    },{
    "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">
            <ul class="nav nav-tabs" role="tablist">
                <li class="active"><a href="#general" role="tab" data-toggle="tab" data-enlarge="1"><span>{% trans "General" %}</span></a></li>
                <li><a href="#options" role="tab" data-toggle="tab"><span>{% trans "Options" %}</span></a></li>
                <li><a href="#advanced" role="tab" data-toggle="tab"><span>{% trans "Advanced" %}</span></a></li>
            </ul>
            <form id="textAddForm" class="XiboForm form-horizontal" method="post" action="{{ urlFor("module.widget.add", {type: module.widget.type, id: playlist.playlistId}) }}">
                <div class="tab-content">
                    <div class="tab-pane active" id="general">
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="well">
                                    <div class="text-center text-info">{% trans "Date/Time templates" %}</div>
                                    <ul id="TickerDataSetColumns">
                                        <li class="ckeditor_snippits" linkedto="ta_text">Clock</li>
                                        <li class="ckeditor_snippits" linkedto="ta_text">Clock|HH:mm</li>
                                        <li class="ckeditor_snippits" linkedto="ta_text">Date</li>
                                        <li class="ckeditor_snippits" linkedto="ta_text">Clock|DD/MM/YYYY</li>
                                    </ul>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group well">
                                    <label class="col-sm-2 control-label" for="ckeditor_library_select">{% trans "Library" %}</label>
                                    <div class="col-sm-10">
                                        <select id="ckeditor_library_select"
                                                class="ckeditor_library_select form-control"
                                                data-linked-to="ta_text"
                                                data-search-url="{{ urlFor("library.search") }}"
                                                data-image-url="{{ urlFor("library.download") }}?preview=1">
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        {% set helpText %}
                            {% trans "Enter the text to display. Please note that the background colour has automatically coloured to your layout background colour." %}
                            {% trans "The red rectangle reflects the size of the region you are editing." %}
                            {% trans "Shift+Enter will drop a single line. Enter alone starts a new paragraph." %}
                        {% endset %}
                        {{ forms.textarea("ta_text", "", "", helpText, "", 10) }}
                    </div>

                    <div class="tab-pane" id="options">
                        {% set title %}{% trans "Name" %}{% endset %}
                        {% set helpText %}{% trans "An optional name for this widget" %}{% endset %}
                        {{ forms.input("name", title, "", helpText) }}

                        {% set title %}{% trans "Effect" %}{% endset %}
                        {% set helpText %}{% trans "Please select the effect that will be used to transition between items. If all items should be output, select None. Marquee effects are CPU intensive and may not be suitable for lower power displays." %}{% endset %}
                        {% set noneOption %}{% trans "None" %}{% endset %}
                        {% set fade %}{% trans "Fade" %}{% endset %}
                        {% set fadeout %}{% trans "Fade Out" %}{% endset %}
                        {% set scrollHorz %}{% trans "Scroll Horizontal" %}{% endset %}
                        {% set scrollVert %}{% trans "Scroll Vertical" %}{% endset %}
                        {% set flipHorz %}{% trans "Flip Horizontal" %}{% endset %}
                        {% set flipVert %}{% trans "Flip Vertical" %}{% endset %}
                        {% set shuffle %}{% trans "Shuffle" %}{% endset %}
                        {% set tileSlide %}{% trans "Tile Slide" %}{% endset %}
                        {% set tileBlind %}{% trans "Tile Blind" %}{% endset %}
                        {% set marqueeLeft %}{% trans "Marquee Left" %}{% endset %}
                        {% set marqueeRight %}{% trans "Marquee Right" %}{% endset %}
                        {% set marqueeUp %}{% trans "Marquee Up" %}{% endset %}
                        {% set marqueeDown %}{% trans "Marquee Down" %}{% endset %}
                        {% set options = [
                        { effectid: "none", effect: noneOption },
                        { effectid: "fade", effect: fade },
                        { effectid: "fadeout", effect: fadeout},
                        { effectid: "scrollHorz", effect: scrollHorz},
                        { effectid: "scrollVert", effect: scrollVert},
                        { effectid: "flipHorz", effect: flipHorz},
                        { effectid: "flipVert", effect: flipVert},
                        { effectid: "shuffle", effect: shuffle},
                        { effectid: "tileSlide", effect: tileSlide},
                        { effectid: "tileBlind", effect: tileBlind},
                        { effectid: "marqueeLeft", effect: marqueeLeft},
                        { effectid: "marqueeRight", effect: marqueeRight},
                        { effectid: "marqueeUp", effect: marqueeUp},
                        { effectid: "marqueeDown", effect: marqueeDown}
                        ] %}
                        {{ forms.dropdown("effect", "single", title, module.getOption("effect"), options, "effectid", "effect", helpText) }}

                        {% set title %}{% trans "Speed" %}{% endset %}
                        {% set helpText %}{% trans "The transition speed of the selected effect in milliseconds (normal = 1000) or the Marquee Speed in a low to high scale (normal = 1)." %}{% endset %}
                        {{ forms.number("speed", title, "", helpText, "effect-controls") }}

                        {% 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") }}
                    </div>

                    <div class="tab-pane" id="advanced">
                        {% set title %}{% trans "Background Colour" %}{% endset %}
                        {% set helpText %}{% trans "The selected effect works best with a background colour. Optionally add one here." %}{% endset %}
                        {{ forms.input("backgroundColor", title, module.getOption("backgroundColor"), helpText, "effect-controls") }}

                        {% set title %}{% trans "Marquee Selector" %}{% endset %}
                        {% set helpText %}{% trans "The selector to use for stacking marquee items in a line when scrolling Left/Right." %}{% endset %}
                        {{ forms.input("marqueeInlineSelector", title, "", helpText, "effect-controls") }}

                        {% set title %}{% trans "Optional JavaScript" %}{% endset %}
                        {{ forms.textarea("javaScript", "", module.getRawNode("javaScript"), title, "", "", 10) }}
                    </div>
                </div>
            </form>
        </div>
    </div>
{% endblock %}