src/NCBS/WebsiteBundle/Resources/views/Exposition/passage_text.html.twig line 1

Open in your IDE?
  1. {% if translation is defined and translation is not null %}
  2.   {% set translation_id = translation.id %}
  3. {% elseif work is defined and work is not null %}
  4.   {% set translation = work.selectTranslation() %}
  5.   {% set translation_id = translation.id %}
  6. {% elseif passage is not null %}
  7.   {% set work = passage.findWork() %}
  8.   {% set translation = work.selectTranslation() %}
  9.   {% set translation_id = translation.id %}
  10. {% endif %}
  11. {% if passage is not empty %}
  12.   {% include "NCBSWBundle:Exposition:display_framework/passage_text.html.twig" %}
  13.   
  14.   {% if work_toc is defined and work_toc is not empty %}
  15.       {% set nColNum = 0 %}
  16.     {% if column_num is defined %}
  17.         {% set nColNum = column_num %}
  18.     {% endif %}
  19.     {% set bHas2Columns = (columns is defined and columns|length == 2) %} 
  20.     {% set bHas3Columns = (columns is defined and columns|length == 3) %}
  21.     {% set sToc = '' %}
  22.     {% set sHrefStart = " href=\"javascript:gotoToc('" %}
  23.     {% set sHrefEnd = "',"~nColNum~");\" " %}
  24.     {% set sClassName = 'list-group-item d-flex justify-content-between align-items-center list-group-item-action' %}
  25.     {% set sActiveElemID = "activeTOC"~nColNum %}
  26.     <div  class="tab-content-header"><i class="fas fa-list-ol"></i> {{ app.session.get('ui_str')["exposition.slider.tab.toc"] }}</div>
  27.           {% for toc_record in work_toc %}              
  28.             {% set link_spec = toc_record['link_spec'] %}{% set href_str = '' %}{% set class_str = " class='"~sClassName~"' " %}{% if passage_id is defined and passage_id == toc_record['startpassage_id'] %}{% elseif bInFrame %}{# 
  29.           #}{% set href_str = sHrefStart~path('exposition_frame_passage', {'translationUrl': toc_record['translation_url'], 'divisionUrls': toc_record['division_url'], 'passageNumber': toc_record['startpassageorder']})~sHrefEnd %}{% elseif bHas3Columns %}{% if nColNum == 3 %}{# 
  30.           #}{% set href_str = sHrefStart~path('arbitrary_three_column', multicolumn_route_params|merge({('column3Details'): link_spec}) )~sHrefEnd %}{% elseif nColNum == 2 %}{% set href_str = sHrefStart~path('arbitrary_three_column', multicolumn_route_params|merge({('column2Details'): link_spec}) )~sHrefEnd %}{% elseif nColNum == 1 %}{% set href_str = sHrefStart~path('arbitrary_three_column', multicolumn_route_params|merge({('column1Details'): link_spec}) )~sHrefEnd %}{% endif %}{% elseif bHas2Columns %}{% if nColNum == 2 %}{% set href_str = sHrefStart~path('arbitrary_two_column', multicolumn_route_params|merge({('column2Details'): link_spec}) )~sHrefEnd %}{% elseif nColNum == 1 %}{% set href_str = sHrefStart~path('arbitrary_two_column', multicolumn_route_params|merge({('column1Details'): link_spec}) )~sHrefEnd %}{% endif %}{#
  31.           #}{% else %}{#
  32.                   #}{% set href_str = sHrefStart~path('exposition_translation_division_passage', {'translationUrl': toc_record['translation_url'], 'divisionUrls': toc_record['division_url'], 'passageNumber': toc_record['startpassageorder']}) %}{% if compare_to is defined and compare_to is not null %}{% set href_str = href_str ~ "?compareTo=" ~ compare_to.url %}{% endif %}{% if compare_to2 is defined and compare_to2 is not null %}{% set href_str = href_str ~ ";;" ~ compare_to2.url %}{% endif %}{% set href_str = href_str ~ sHrefEnd %}{# 
  33.               #}{% endif %}     
  34.               {% if passage_order is defined and passage_order >= toc_record['startpassageorder'] and (toc_record['nextstartpassageorder'] == '' or passage_order < toc_record['nextstartpassageorder']) %} 
  35.                   {% set class_str = " class='"~sClassName~" active' id='"~sActiveElemID~"'" %}
  36.               {% endif %}         
  37.             {% set sToc = sToc ~"<a "~href_str~" " ~ class_str ~ " >"~toc_record['toc_text']~" <span class='badge badge-pill'>"~toc_record['link_text']~"</span></a> " %}     
  38.         {% endfor %}
  39.         {{ sToc|trim|raw }}
  40.   {% endif %}
  41.   
  42.   {% if related_concept_list is defined and related_concept_list is not empty %}
  43.         <p><b><i>{{ app.session.get('ui_str')["related.concepts"] }}:</i></b>
  44.        {% for curr_record in related_concept_list %}              
  45.       <p><a href="/gte?t={{ curr_record.translation_id }}&l={{ translation.getLanguage.id }}" target=_blank >{{ curr_record.title }}</a>
  46.     {% endfor %}
  47.   {% endif %}
  48.   {% set nPct = app.request.get('pct') %}
  49.   {% if nPct > 0 %}
  50.       <script>
  51.           function scrollToPercentage(element, percentage) {
  52.             var nMoreOffset = -30;
  53.             var nOffset = getElementTopPosition(element) + nMoreOffset;          
  54.           const scrollHeight = element.scrollHeight;             
  55.           const scrollTopPosition = scrollHeight * (percentage / 100) + nOffset;        
  56.             setTimeout(function () {
  57.                 window.scrollTo({ top: scrollTopPosition });    
  58.                 //element.animate({ scrollTop: scrollTopPosition }, 300);            
  59.             },500);
  60.         }
  61.                 
  62.         function getElementTopPosition(element) {
  63.           let topPosition = element.offsetTop;
  64.           let currentElement = element.offsetParent;
  65.         
  66.           while (currentElement !== null) {
  67.             topPosition += currentElement.offsetTop;
  68.             currentElement = currentElement.offsetParent;
  69.           }
  70.           return topPosition;
  71.         }
  72.         
  73.         $( document ).ready(function() {
  74.             const textElement = document.getElementById('tts0');
  75.             scrollToPercentage(textElement, {{ nPct }});            
  76.         });                
  77.       </script>
  78.   {% endif %}
  79. {% else %}
  80.   <p>{{ app.session.get('ui_str')["exposition.passage.notfound"] }}</p>
  81. {% endif %}