{#
    LimeSurvey
    Copyright (C) 2007-2017 The LimeSurvey Project Team / Louis Gac
    All rights reserved.
    License: GNU/GPL License v2 or later, see LICENSE.php
    LimeSurvey is free software. This version may have been modified pursuant
    to the GNU General Public License, and as distributed it includes or
    is derivative of works licensed under the GNU General Public License or
    other free or open source software licenses.
    See COPYRIGHT.php for copyright notices and details.

    (¯`·._.·(¯`·._.· Default survey template options ._.·´¯)·._.·´¯)

    This is the form for the option parameters of the basic default template.

#}



{#
    The default template offers the variety of the basic bootswatch styles
#}

{% set bootswatchOption = '' %}

{% set brandlogofileOptions , brandlogofileInheritFilename, brandlogofileInheritPreview = '', '', '' %}

{# For surveyspecific settings add an inherit option #}
{% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
    {% set bootswatchOption = bootswatchOption ~ '<option value="inherit">'~ gT("Inherit")  ~' ['~ gT("inherited value:") ~'</option>' %}
{% endif %}
{# List of Bootswatch styles #}
{% set bootswatchOption %}
{{bootswatchOption}}
<option value="css/variations/basic.min.css">
    Basic Bootstrap</option>
<option value="css/variations/cerulean.min.css">
    Cerulean</option>
<option value="css/variations/cosmos.min.css">
    Cosmos</option>
<option value="css/variations/cyborg.min.css">
    Cyborg</option>
<option value="css/variations/darkly.min.css">
    Darkly</option>
<option value="css/variations/flatly.min.css">
    Flatly</option>
<option value="css/variations/journal.min.css">
    Journal</option>
<option value="css/variations/lumen.min.css">
    Lumen</option>
<option value="css/variations/paper.min.css">
    Paper</option>
<option value="css/variations/readable.min.css">
    Readable</option>
<option value="css/variations/sandstone.min.css">
    Sandstone</option>
<option value="css/variations/simplex.min.css">
    Simplex</option>
<option value="css/variations/slate.min.css">
    Slate</option>
<option value="css/variations/spacelab.min.css">
    Spacelab</option>
<option value="css/variations/superhero.min.css">
    Superhero</option>
<option value="css/variations/united.min.css">
    United</option>
<option value="css/variations/yeti.min.css">
    Yeti</option>
{% endset %}


{#
    The options page
#}
<div class="container-fluid" style="position:relative">
    {# Small loading animation to give the scripts time to parse and render the correct values #}
    <div class="" style="display:none;height:100%;width:100%;position:absolute;left:0;top:0;background:rgb(255,255,255);background:rgba(235,235,235,0.8);z-index:2000;">
        <div style="position:absolute; left:49%;top:35%;" class="text-center">
            <i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
        </div>
    </div>
    <div class="row">
        {# Begin template option form #}
        <form class='form action_update_options_string_form' action=''>

            {# If this is a surveyspecific settings page, offer the possibility to do a full inheritance of the parent template #}
            {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                <div class='row' id="general_inherit_active">
                    <div class='form-group row'>
                        <label for='simple_edit_options_general_inherit' class='control-label'>{{gT("Inherit everything" )}}</label>
                        <div class='col-sm-12'>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default">
                                    <input id="general_inherit_on" name='general_inherit' type='radio' value='on' class='selector_option_general_inherit ' data-id='simple_edit_options_general_inherit'/>
                                    {{ gT("Yes" ) }}
                                </label>
                                <label class="btn btn-default">
                                    <input id="general_inherit_off" name='general_inherit' type='radio' value='off' class='selector_option_general_inherit ' data-id='simple_edit_options_general_inherit'/>
                                    {{ gT("No") }}
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row action_hide_on_inherit">
                    <hr/>
                </div>
            {% endif %}

            {# First settings row #}
            <div class='row action_hide_on_inherit'>

                {# Show Clear And Exit #}
                <div class='col-sm-12 col-md-4 col-lg-3'>
                    <div class='form-group row'>
                        <label for='simple_edit_options_showclearall' class='control-label'> {{ gT("Show Clear All Button") }} </label>
                        <div class='col-sm-12'>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default">
                                    <input type='radio' name='showclearall' value='on' class='selector_option_radio_field simple_edit_options_showclearall ' data-id='showclearall'/>
                                    {{ gT("Yes") }}
                                </label>
                                <label class="btn btn-default">
                                    <input type='radio' name='showclearall' value='off' class='selector_option_radio_field simple_edit_options_showclearall ' data-id='showclearall'/>
                                    {{ gT("No") }}
                                </label>
                                {# If this is a root template setting, don't show the inherit button #}
                                {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                                    <label class="btn btn-default" title="{{ gT("Inherited value:") }} ">
                                        <input type='radio' name='showclearall' value='inherit' class='selector_option_radio_field simple_edit_options_showclearall ' data-id='showclearall'/>
                                        {{ gT("Inherit") }} [{{ oParentOptions.showclearall }}]
                                    </label>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>

                {# questionhelptextposition #}
                <div class='col-sm-12 col-md-4 col-lg-3'>
                    <div class='form-group row'>
                        <label for='simple_edit_options_questionhelptextposition' class='control-label'>{{ gT("Question help text position") }}</label>
                        <div class='col-sm-12'>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default">
                                    <input type='radio' name='questionhelptextposition' value='top' class='selector_option_radio_field simple_edit_options_questionhelptextposition ' data-id='questionhelptextposition'/>
                                    {{ gT("Top") }}
                                </label>
                                <label class="btn btn-default">
                                    <input type='radio' name='questionhelptextposition' value='bottom' class='selector_option_radio_field simple_edit_options_questionhelptextposition ' data-id='questionhelptextposition'/>
                                    {{ gT("Bottom") }}
                                </label>
                                {# If this is a root template setting, don't show the inherit button #}
                                {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                                    <label class="btn btn-default">
                                        <input type='radio' name='questionhelptextposition' value='inherit' class='selector_option_radio_field simple_edit_options_questionhelptextposition ' data-id='questionhelptextposition'/>
                                        {{ gT("Inherit") }} [{{ oParentOptions.questionhelptextposition }}]
                                    </label>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>

                <div class='col-sm-12 col-md-4 col-lg-4'>
                    {# Show popups #}
                    <div class='form-group row'>
                        <label for='simple_edit_options_showpopups' class='control-label' {{ showpopups_disabled_qtip }}>{{ gT("Show popups") }}</label>
                        <div class='col-sm-12'>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default control-label" {{ showpopups_disabled }}>
                                        <input type='radio' name='showpopups' value='1' {{ showpopups_disabled }} class='selector_option_radio_field simple_edit_options_showpopups ' data-id='showpopups'/>
                                        {{ gT("Popup") }}
                                    </label>
                                    <label class="btn btn-default" {{ showpopups_disabled }}>
                                        <input type='radio' name='showpopups' value='0' {{ showpopups_disabled }} class='selector_option_radio_field simple_edit_options_showpopups ' data-id='showpopups'/>
                                        {{ gT("On page") }}
                                    </label>
                                    <label class="btn btn-default" {{ showpopups_disabled }}>
                                        <input type='radio' name='showpopups' value='-1' {{ showpopups_disabled }} class='selector_option_radio_field simple_edit_options_showpopups ' data-id='showpopups'/>
                                        {{ gT("No") }}
                                    </label>
                                    {# If this is a root template setting, don't show the inherit button #}
                                    {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                                        <label class="btn btn-default" {{ showpopups_disabled }}>
                                            <input type='radio' name='showpopups' value='inherit' class='selector_option_radio_field simple_edit_options_showpopups ' data-id='showpopups'/>
                                        {{ gT("Inherit") }} [{{ oParentOptions.showpopups }}]
                                        </label>
                                    {% endif %}
                            </div>
                        </div>
                    </div>
                </div>

                {# Fix num auto (and real num value) #}
                <div class='col-sm-12 col-md-4 col-lg-3'>
                    <div class='form-group row'>
                        <label for='simple_edit_options_fixnumauto' class='control-label'>{{ gT("Fix automatically numeric value") }}</label>
                        <div class='col-sm-12'>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default">
                                    {# bFixNumAuto : 1 and bNumRealValue : 0 #}
                                    <input type='radio' name='fixnumauto' value='enable' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
                                    {{ gT("Yes") }}
                                </label>
                                <label class="btn btn-default">
                                    {# bFixNumAuto : 0 and bNumRealValue : 0 #}
                                    <input type='radio' name='fixnumauto' value='partial' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
                                    {{ gT("For expression") }}
                                </label>
                                <label class="btn btn-default">
                                    {# bFixNumAuto : 0 and bNumRealValue : 1 #}
                                    <input type='radio' name='fixnumauto' value='disable' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
                                    {{ gT("No") }}
                                </label>
                                {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                                    <label class="btn btn-default">
                                        <input type='radio' name='fixnumauto' value='inherit' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
                                        {{ gT("Inherit") }} [{{ oParentOptions.fixnumauto == gT("No") ? gT("Default") : oParentOptions.fixnumauto }}]
                                    </label>
                                {% else %}
                                    {# Since added after theme distribution and don't want reset : use empty value for leave default #}
                                    <label class="btn btn-default">
                                        <input type='radio' name='fixnumauto' value='off' class='selector_option_radio_field simple_edit_options_fixnumauto' data-id='fixnumauto'/>
                                        {{ gT("Default") }}
                                    </label>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>

                {# Container #}
                <div class='col-xs-12 col-sm-6 col-md-4 col-lg-3'>
                    <div class='form-group row'>
                        <label for='simple_edit_options_container' class='control-label'> {{ gT("Survey container") }} </label>
                        <div class='col-sm-12'>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default">
                                    <input type='radio' name='container' value='on' class='selector_option_radio_field simple_edit_options_container ' data-id='container'/>
                                    {{ gT("Yes") }}
                                </label>
                                <label class="btn btn-default">
                                    <input type='radio' name='container' value='off' class='selector_option_radio_field simple_edit_options_container ' data-id='container'/>
                                    {{ gT("No") }}
                                </label>
                                {# If this is a root template setting, don't show the inherit button #}
                                {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                                    <label class="btn btn-default">
                                        <input type='radio' name='container' value='inherit' class='selector_option_radio_field simple_edit_options_container ' data-id='container'/>
                                        {{ gT("Inherit") }} [{{ oParentOptions.container }}]
                                    </label>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>

                {# hideprivacyinfo #}
                <div class='col-xs-12 col-sm-6 col-md-4 col-lg-3'>
                    <div class='form-group row'>
                        <label for='simple_edit_options_hideprivacyinfo' class='control-label'>{{ gT("Hide privacy info") }}</label>
                        <div class='col-sm-12'>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default">
                                    <input type='radio' name='hideprivacyinfo' value='on' class='selector_option_radio_field simple_edit_options_hideprivacyinfo ' data-id='hideprivacyinfo'/>
                                    {{ gT("Yes") }}
                                </label>
                                <label class="btn btn-default">
                                    <input type='radio' name='hideprivacyinfo' value='off' class='selector_option_radio_field simple_edit_options_hideprivacyinfo ' data-id='hideprivacyinfo'/>
                                    {{ gT("No") }}
                                </label>
                                {# If this is a root template setting, don't show the inherit button #}
                                {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                                    <label class="btn btn-default">
                                        <input type='radio' name='hideprivacyinfo' value='inherit' class='selector_option_radio_field simple_edit_options_hideprivacyinfo ' data-id='hideprivacyinfo'/>
                                        {{ gT("Inherit") }} [{{ oParentOptions.hideprivacyinfo }}]
                                    </label>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class='row action_hide_on_inherit'>
                <hr/>
            </div>

            <!-- Brand Logo -->
            <div class='row action_hide_on_inherit'>
                <div class='col-sm-12 col-md-3'>
                    {# Brandlogo #}
                    <div class='form-group row'>
                        <label for='simple_edit_options_brandlogo' class='control-label'>{{ gT("Brandlogo") }}</label>
                        <div class='col-sm-12'>
                            <div class="btn-group" data-toggle="buttons">
                                <label class="btn btn-default">
                                    <input type='radio' name='brandlogo' value='on' class='selector_option_radio_field ' data-id='simple_edit_options_brandlogo'/>
                                    {{ gT("Yes") }}
                                </label>
                                <label class="btn btn-default">
                                    <input type='radio' name='brandlogo' value='off' class='selector_option_radio_field ' data-id='simple_edit_options_brandlogo'/>
                                    {{ gT("No") }}
                                </label>
                                {# If this is a root template setting, don't show the inherit button #}
                                {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                                    <label class="btn btn-default">
                                        <input type='radio' name='brandlogo' value='inherit' class='selector_option_radio_field ' data-id='simple_edit_options_brandlogo'/>
                                        {{ gT("Inherit") }} [{{ oParentOptions.brandlogo }}]
                                    </label>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>
                <div class='col-sm-8 col-md-6'>
                    {#  Brandlogo file selector #}
                    <div class='form-group row'>
                        <label for='simple_edit_options_brandlogofile' class='control-label'>{{ gT("Brandlogo file")}}</label>
                        <div class='col-sm-12'>
                            <select class='form-control selector_option_value_field selector_radio_childfield selector_image_selector' data-parent="brandlogo" id='simple_edit_options_brandlogofile' name='brandlogofile'>
                                {% set optgroup = '' %}
                                {% for image in templateConfiguration.imageFileList %}
                                    {% if image.group != optgroup %}
                                        {% if optgroup != '' %}
                                            {% set brandlogofileOptions = brandlogofileOptions ~ '</optgroup>' %}
                                        {% endif %}
                                        {% set brandlogofileOptions = brandlogofileOptions ~ '<optgroup label="' ~ image.group ~ '">'  %}
                                        {% set optgroup = image.group %}
                                    {% endif %}
                                    {% if oParentOptions.brandlogofile == image.filepath %} 
                                        {% set brandlogofileInheritPreview = brandlogofileInheritPreview ~ image.preview %} 
                                        {% set brandlogofileInheritFilename = brandlogofileInheritFilename ~ image.filename %} 
                                    {% endif %}
                                    {% set brandlogofileOptions = brandlogofileOptions ~ '<option data-lightbox-src="' ~ image.preview ~ '" value="' ~ image.filepath ~ '">' ~ image.filename ~ '</option>' %}
                                {% endfor %}
                                {% set brandlogofileOptions = brandlogofileOptions ~ '</optgroup>' %}
                                {% if templateConfiguration.sid is not empty or templateConfiguration.gsid is not empty %}
                                    {% set brandlogofileOptions = '<option data-lightbox-src="' ~ brandlogofileInheritPreview ~ '" value="inherit">' ~ gT("Inherit")~ ' [' ~ gT("inherited value:") ~ ' ' ~ brandlogofileInheritFilename ~ ']</option>' ~ brandlogofileOptions %}
                                {% endif %}
                                {{ brandlogofileOptions }}
                            </select>
                        </div>
                    </div>
                </div>
                <div class='col-sm-4 col-md-2'>
                    <br/>
                    <button class="btn btn-default selector__open_lightbox" data-target="#simple_edit_options_brandlogofile"> {{ gT('Preview image')}}</button>
                </div>
            </div>
            <div class='row ls-space margin top-15 bottom-15 '>
                <hr/>
            </div>
            <div class='row'>
                <div class='col-sm-12'>
                    <div class='panel panel-default'>
                        <div class='panel-heading'>{{ gT("Bootstrap theme") }}</div>
                        <div class='panel-body'>
                            {# Bootstrap Bootswatch theme #}
                            <div class='form-group row'>
                                <label for='simple_edit_cssframework' class='control-label'>{{ gT("Bootswatch theme") }}</label>
                                <div class='col-sm-12'>
                                    <select class='form-control selector_cssframework_value_field' id='simple_edit_cssframework' name='cssframework'>
                                        {{bootswatchOption}}
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </form>
    </div>

    <div class='row action_hide_on_inherit'>
        {# Upload an image #}
        <div class="container-fluid ls-space margin bottom-15">
            <div class="row ls-space margin bottom-15">
                <div class="col-sm-6">
                    {{ sprintf( gT("Upload an image (maximum size: %d MB):"), (templateConfiguration.maxFileSize/1024/1024) ) }}
                </div>
                <div class="col-sm-6">
                {{ C.Html.form(createUrl('/admin/themes/sa/upload'), 'post', { 'id' : 'upload_frontend', 'name' : 'upload_frontend', 'enctype' :'multipart/form-data' }) }}
                    <span id="fileselector_frontend">
                        <label class="btn btn-default col-xs-8" for="upload_image_frontend">
                            <input class="hidden" id="upload_image_frontend" name="upload_image_frontend" type="file">
                            <i class="fa fa-upload ls-space margin right-10"></i>
                            {{ gT("Upload") }}
                        </label>
                    </span>

                        <input type='hidden' name='templatename' value='{{ templateConfiguration.template_name }}' />
                        <input type='hidden' name='templateconfig' value='{{ templateConfiguration.id }}' />
                        <input type='hidden' name='action' value='templateuploadimagefile' />
                    </form>
                </div>
            </div>
            <div class="row">
                <div class="progress">
                    <div id="upload_progress_frontend" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
                        <span class="sr-only">0%</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" tabindex="-1" role="dialog" id="lightbox-modal">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title selector__title"> </h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-xs-12">
                            <img class="selector__image img-responsive" src="" alt="title"  />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
