{#
/**
 * List DropDown select Html
 *
 * @var $sOptions         : the select options, generated with the view item_options.php
 * @var $sOther           : the other input field, generated with the view item_noanswer.php
 *
 * @var $name
 * @var $dropdownSize
 * @var $checkconditionFunction
 * @var $select_show_hide
 *
 */
#}


{% set data_live_search = (question_template_attribute.show_search == 'default' or question_template_attribute.show_search is empty or question_template_attribute.show_search == 'false') ? '' : "data-live-search='true'" %}
{% set show_tick = (question_template_attribute.show_tick == 'default' or question_template_attribute.show_tick is empty or question_template_attribute.show_tick == 'false') ? '' : "show-tick" %}
{% set width_entry = (question_template_attribute.width_entry == 'default' or question_template_attribute.width_entry is empty or question_template_attribute.width_entry == 'false') ? "data-width='auto'" : '' %}

<!-- List Dropdown -->

<!-- answer-->
<div class="mb-3 row align-items-center">
    <div class="{{ coreClass }} col-auto">
        <select
                class="form-control list-question-select {{ show_tick }}"
                {{ data_live_search }}
                {{ width_entry }}
                data-none-selected-text=''
                name="{{ name }}"
                id="answer{{ name }}"
                data-style="btn-outline-secondary"
                {% if dropdownSize %} size={{ dropdownSize }} {% endif %}
                aria-labelledby="ls-question-text-{{ basename }}"
        >
                {# rows/option.php #}
                {{ sOptions }}
        </select>

        {# Value for expression manager javascript (use id) ; no need to submit #}
        {{ C.Html.hiddenField("java"~name,value,({
            'id' : "java"~name,
            'disabled' : "disabled",
        }))
        }}
    </div>
    {# rows/othertext.php #}
    {{ sOther }}
    <script type="text/javascript">
        $(function () {
            var selectPicker = $('#answer{{ name }}').selectpicker();

            // Custom js to make width setting work with this beta version:
            {% if width_entry != '' %}
            selectPicker.on('loaded.bs.select', function () {
                selectPicker.selectpicker('open');
                var dropdown = selectPicker.parent();
                var width = dropdown.find('.dropdown-menu.show').width();
                dropdown.css('width', width);
                selectPicker.selectpicker('toggle');
                $('.bootstrap-select .btn.dropdown-toggle').blur();
            });
            {% endif %}
        });

    </script>
</div>
<!-- end of answer  -->
