{# dropdown_target should be:
1 or 'left' to select translation in left column of two-column translation comparison view (without changing right column)
2 or 'right' to select translation in right column of two-column translation comparison view (without changing left column)
3 or '3col' to select translation in third column of three-column translation comparison view (without changing left/right column)
'index' to link to index page for translations (not displaying a passage)
null or undefined to link to translations of the current passage in a one-column view
'add' to link from a one-column view to a two-column view (with the current translation in the left column and the new translation in the right column)
'multicolumn' to change one column of an arbitrary multicolumn view (the column_num variable will indicate which column)
'readingplan' for translations in reading plans
'quickview' for translations in quick view (search)
#}
{% if dropdown_target is not defined %}
{% set dropdown_target = null %}
{% elseif dropdown_target|lower == 'left' %}
{% set dropdown_target = 1 %}
{% elseif dropdown_target|lower == 'right' %}
{% set dropdown_target = 2 %}
{% elseif dropdown_target|lower == '3col' %}
{% set dropdown_target = 3 %}
{% endif %}
{# Differentiate between simple one-column view, two-column translation comparison, and multicolumn with independent navigation #}
{% set three_column = (translation3 is defined and translation3 is not null) %}
{% set two_column = (not three_column and (translation2 is defined and translation2 is not null)) %}
{% set multicolumn = (dropdown_target == 'multicolumn') %}
{% set readingplan = (dropdown_target == 'readingplan') %}
{% set quickview = (dropdown_target == 'quickview') %}
<select id="compare_dd" onchange="{{ quickview? "loadQuickview(this.value);" : "location = this.value;" }}" class="form-control form-control-sm" style="display:inline;max-width:280px;">
{% set currently_selected = (dropdown_target == 1) ? translation1 : (dropdown_target == 2) ? translation2 : (dropdown_target == 3) ? translation3 : translation %}
{% if dropdown_target == 'add' %}
<option selected value="#">{{ app.session.get('ui_str')["bible.biblestudy.comparetranslations"] }}</option>
{% elseif two_column %}
{# Dropdown menu item to remove this column, showing only the other one #}
{% if dropdown_target == 2 %}
{% set contents_target = contents1 %}
{% set translation_target = translation1 %}
{% else %}
{% set contents_target = contents2 %}
{% set translation_target = translation2 %}
{% endif %}
{# If the content doesn't exist in one of the translations, do we just want to not show the "(remove)" option? #}
{% if contents_target|length > 0 %}
{% set v1 = contents_target|first|first.findMainVerse() %}
{% set vn = contents_target|last|last.findMainVerse() %}
{% set c1 = v1.chapter %}
{% set cn = vn.chapter %}
{% if contents_target|length == 1 %}
{% if v1.id == c1.verses|first.id and vn.id == cn.verses|last.id %}
{% set url_1col = uri(c1) %}
{% elseif v1.id == vn.id %}
{% set url_1col = uri(v1) %}
{% else %}
{% set url_1col = path('bible_verse_range', {'translationUrl': translation_target.url, 'bookUrl': c1.book.url, 'chapterIndex': c1.ordering, 'verseStartIndex': v1.indexDisplay, 'verseEndIndex': vn.indexDisplay}) %}
{% endif %}
{% else %} {# contents_target|length > 1 #}
{% if v1.id == c1.verses|first.id and vn.id == cn.verses|last.id %}
{% set url_1col = path('bible_chapter_range', {'translationUrl': translation_target.url, 'bookUrl': c1.book.url, 'chapterStartIndex': c1.ordering, 'chapterEndIndex': cn.ordering}) %}
{% else %}
{% set url_1col = path('bible_chapter_verse_range', {'translationUrl': translation_target.url, 'bookUrl': c1.book.url, 'chapterStartIndex': c1.ordering, 'chapterEndIndex': cn.ordering, 'verseStartIndex': v1.indexDisplay, 'verseEndIndex': vn.indexDisplay}) %}
{% endif %}
{% endif %}
<script>
aRemoveLink[{{ dropdown_target }}] = "{{ url_1col }}";
</script>
<option value="{{ url_1col }}">{{ app.session.get('ui_str')["bible.breadcrumbs.removetranslation"] }}</option>
{% endif %}
{% elseif three_column %}
{# Dropdown menu item to remove this column, showing only the other two columns #}
{% set currentPath = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
{% set nOffset = 2 %}
{% if current_locale_code != 'en' %}
{% set nOffset = 3 %}
{% endif %}
{% set aPath = currentPath |split('/') %}
{% set url_2col = '' %}
{% for item in aPath %}
{% if loop.index0 != dropdown_target+nOffset %}
{% if url_2col == '' %}
{% set url_2col = url_2col~item %}
{% else %}
{% set url_2col = url_2col~'/'~item %}
{% endif %}
{% endif %}
{% endfor %}
{% set url_2col = '/'~url_2col %}
<option value="{{ url_2col }}">{{ app.session.get('ui_str')["bible.breadcrumbs.removetranslation"] }}</option>
<script>
aRemoveLink[{{ dropdown_target }}] = "{{ url_2col }}";
</script>
{% endif %}
{% if currently_selected is null %}
<option selected value="#">{{ app.session.get('ui_str')["bible.translation.unknown"] }}</option>
{% endif %}
{% include 'NCBSWBundle:Bible:interface/translation_dropdown/language_section.html.twig' %}
</select>