custom/plugins/C108Faq/src/Resources/views/storefront/element/cms-element-faq.html.twig line 1

Open in your IDE?
  1. {% block element_faq %}
  2. {# Settings Allgemein #}
  3. {% set id = element.id %}
  4. {% set c108faqhighlightcolor = element.config.c108faqhighlightcolor.value %}
  5. {% set c108faqbannertype = element.config.c108faqbannertype.value %}
  6. {% set c108faqbannerimg = element.config.c108faqbannerimg.value %}
  7. {% set c108faqbannertitle = element.config.c108faqbannertitle.value %}
  8. {% set currBannerTitle = asset('bundles/c108faq/static/img/cms/'~ c108faqbannertitle ~'.png') %}
  9. {% set c108faqsectionshideable = element.config.c108faqsectionshideable.value|default(false) %}
  10. {# Settings Bereich 1 #}
  11. {% set c108faqsection1title = element.config.c108faqsection1title.value %}
  12. {% set c108faqsection1text = element.config.c108faqsection1text.value %}
  13. {% set c108faqsection1icon = element.config.c108faqsection1icon.value %}
  14. {% set c108faqsection1icontype = element.config.c108faqsection1icontype.value %}
  15. {% set c108faqsection1iconpath = element.config.c108faqsection1iconpath.value %}
  16. {% set c108faqsection1questionsArray = element.config.c108faqsection1questionsArray.value %}
  17. {# Settings Bereich 2 #}
  18. {% set c108faqsection2title = element.config.c108faqsection2title.value %}
  19. {% set c108faqsection2text = element.config.c108faqsection2text.value %}
  20. {% set c108faqsection2icon = element.config.c108faqsection2icon.value %}
  21. {% set c108faqsection2icontype = element.config.c108faqsection2icontype.value %}
  22. {% set c108faqsection2iconpath = element.config.c108faqsection2iconpath.value %}
  23. {% set c108faqsection2questionsArray = element.config.c108faqsection2questionsArray.value %}
  24. {# Settings Bereich 3 #}
  25. {% set c108faqsection3title = element.config.c108faqsection3title.value %}
  26. {% set c108faqsection3text = element.config.c108faqsection3text.value %}
  27. {% set c108faqsection3icon = element.config.c108faqsection3icon.value %}
  28. {% set c108faqsection3icontype = element.config.c108faqsection3icontype.value %}
  29. {% set c108faqsection3iconpath = element.config.c108faqsection3iconpath.value %}
  30. {% set c108faqsection3questionsArray = element.config.c108faqsection3questionsArray.value %}
  31. {# FAQ Element#}
  32. <div class="cms-element-faq" style="height: 100%; width: 100%">
  33. {% block element_faq_inner %}
  34. {# Background image #}
  35. {# Shipped image #}
  36. {% if c108faqbannertype == 'shippedimage' %}
  37. {% set currImgPath = asset('bundles/c108faq/static/img/cms/'~ c108faqbannerimg ~'.jpg') %}
  38. {% endif %}
  39. {# Own image #}
  40. {% if c108faqbannertype == 'ownimage' %}
  41. {% set currMediaId = element.config.media.value %}
  42. {% if currMediaId %}
  43. {% set currMediaCollection = searchMedia([currMediaId], context.context) %}
  44. {% set currMediaObject = currMediaCollection.get(currMediaId) %}
  45. {% set currImgPath = currMediaObject.url %}
  46. {% else %}
  47.   {% set currImgPath = '' %}
  48. {% endif %}
  49. {% endif %}
  50. <div class="c108-faq-banner" style="background-image:url('{{ currImgPath }}');">
  51. <div class="c108-faq-inside" style="background-image:url('{{ currBannerTitle }}');">
  52. </div>
  53. </div>
  54. {# Background image Ende #}
  55. {# Boxes #}
  56. <div class="cms-element-faq-boxes">
  57. {# Bereich 1 #}
  58. <div class="c108faqwrappertype-{{ c108faqsection1icontype }} c108faqwrapper-einfach c108-faq-section-box">
  59. <div class="c108faq-content">
  60. {# Case 1: Shopware Icon #}
  61. {% if c108faqsection1icontype == 'shippedicon' %}
  62. <div class="c108-icon-wrapper">
  63. <span class="icon icon-{{ c108faqsection1icon }}" style="color:{{ c108faqhighlightcolor }};">
  64. {{ source('@Storefront/assets/icon/default/'~ c108faqsection1icon ~'.svg', ignore_missing = true) }}
  65. </span>
  66. </div>
  67. {# Case 1: Shopware Icon - Ende #}
  68. {# Case 2: Own Icon #}
  69. {% elseif c108faqsection1icontype == 'ownicon' %}
  70. <div class="c108-icon-wrapper c108faqowniconwrapper">
  71. <img src="{{ c108faqsection1iconpath }}" alt="{{ c108faqsection1title }} Icon">
  72. </div>
  73. {% endif %}
  74. {# Case 2: Own Icon- Ende #}
  75. <div class="c108-faq-text-wrapper">
  76. <div class="c108-faq-section-title-boxes">{{ c108faqsection1title }}</div>
  77. <div class="c108-faq-section-text-boxes"><p>{{ c108faqsection1text|nl2br }}</p></div>
  78. </div>
  79. </div>
  80. </div>
  81. {# Bereich 1: Ende #}
  82. {# Bereich 2 #}
  83. <div class="c108faqwrappertype-{{ c108faqsection2icontype }} c108faqwrapper-einfach c108-faq-section-box">
  84. <div class="c108faq-content">
  85. {# Case 1: Shopware Icon #}
  86. {% if c108faqsection2icontype == 'shippedicon' %}
  87. <div class="c108-icon-wrapper">
  88. <span class="icon icon-{{ c108faqsection2icon }}" style="color:{{ c108faqhighlightcolor }};">
  89. {{ source('@Storefront/assets/icon/default/'~ c108faqsection2icon ~'.svg', ignore_missing = true) }}
  90. </span>
  91. </div>
  92. {# Case 1: Shopware Icon - Ende #}
  93. {# Case 2: Own Icon #}
  94. {% elseif c108faqsection2icontype == 'ownicon' %}
  95. <div class="c108-icon-wrapper c108faqowniconwrapper">
  96. <img src="{{ c108faqsection2iconpath }}" alt="{{ c108faqsection2title }} Icon">
  97. </div>
  98. {% endif %}
  99. {# Case 2: Own Icon- Ende #}
  100. <div class="c108-faq-text-wrapper">
  101. <div class="c108-faq-section-title-boxes">{{ c108faqsection2title }}</div>
  102. <div class="c108-faq-section-text-boxes"><p>{{ c108faqsection2text|nl2br }}</p></div>
  103. </div>
  104. </div>
  105. </div>
  106. {# Bereich 2: Ende #}
  107. {# Bereich 1 #}
  108. <div class="c108faqwrappertype-{{ c108faqsection3icontype }} c108faqwrapper-einfach c108-faq-section-box">
  109. <div class="c108faq-content">
  110. {# Case 1: Shopware Icon #}
  111. {% if c108faqsection3icontype == 'shippedicon' %}
  112. <div class="c108-icon-wrapper">
  113. <span class="icon icon-{{ c108faqsection3icon }}" style="color:{{ c108faqhighlightcolor }};">
  114. {{ source('@Storefront/assets/icon/default/'~ c108faqsection3icon ~'.svg', ignore_missing = true) }}
  115. </span>
  116. </div>
  117. {# Case 1: Shopware Icon - Ende #}
  118. {# Case 2: Own Icon #}
  119. {% elseif c108faqsection3icontype == 'ownicon' %}
  120. <div class="c108-icon-wrapper c108faqowniconwrapper">
  121. <img src="{{ c108faqsection3iconpath }}" alt="{{ c108faqsection3title }} Icon">
  122. </div>
  123. {% endif %}
  124. {# Case 2: Own Icon- Ende #}
  125. <div class="c108-faq-text-wrapper">
  126. <div class="c108-faq-section-title-boxes">{{ c108faqsection3title }}</div>
  127. <div class="c108-faq-section-text-boxes"><p>{{ c108faqsection3text|nl2br }}</p></div>
  128. </div>
  129. </div>
  130. </div>
  131. {# Bereich 3: Ende #}
  132. {# Suche #}
  133. <div class="c108-faq-suchfeld-holder">
  134. <label class="c108-faq-search-title">{{ 'faq.element.labelsearch'|trans }}
  135. <input id="{{ id }}-searchField" type="text" name="faqsuchfeld" class="c108-faq-suchfeld">
  136. </label>
  137. </div>
  138. {# Suche: Ende #}
  139. </div>
  140. {# Boxes inkl. Suche: Ende #}
  141. {# Fragen Bereich #}
  142. <div id="{{ id }}-questionwrapper" class="c108-faq-question-section" >
  143. {# Fragen Bereich 1 #}
  144. <div class="c108-faq-section-outer">
  145. <div class="c108-faq-section-title{% if c108faqsectionshideable == true %} c108-faq-section-hideable is-shown{% endif %}">
  146. {{ c108faqsection1title }}
  147. </div>
  148. {% for currentQuestion in c108faqsection1questionsArray %}
  149. {% if currentQuestion.question is not empty and currentQuestion.answer is not empty %}
  150. <button class="questiontab"><span>{{ currentQuestion.question }}</span></button>
  151. <div class="answertab">
  152. <p>{{ currentQuestion.answer|nl2br}}</p>
  153. </div>
  154. {% endif %}
  155. {% endfor %}
  156. </div>
  157. {# Fragen Bereich 1: Ende #}
  158. {# Fragen Bereich 2 #}
  159. <div class="c108-faq-section-outer">
  160. <div class="c108-faq-section-title{% if c108faqsectionshideable == true %} c108-faq-section-hideable is-shown{% endif %}">
  161. {{ c108faqsection2title }}
  162. </div>
  163. {% for currentQuestion in c108faqsection2questionsArray %}
  164. {% if currentQuestion.question is not empty and currentQuestion.answer is not empty %}
  165. <button class="questiontab"><span>{{ currentQuestion.question }}</span></button>
  166. <div class="answertab">
  167. <p>{{ currentQuestion.answer|nl2br}}</p>
  168. </div>
  169. {% endif %}
  170. {% endfor %}
  171. </div>
  172. {# Fragen Bereich 2: Ende #}
  173. {# Fragen Bereich 3 #}
  174. <div class="c108-faq-section-outer">
  175. <div class="c108-faq-section-title{% if c108faqsectionshideable == true %} c108-faq-section-hideable is-shown{% endif %}">
  176. {{ c108faqsection3title }}
  177. </div>
  178. {% for currentQuestion in c108faqsection3questionsArray %}
  179. {% if currentQuestion.question is not empty and currentQuestion.answer is not empty %}
  180. <button class="questiontab"><span>{{ currentQuestion.question }}</span></button>
  181. <div class="answertab">
  182. <p>{{ currentQuestion.answer|nl2br}}</p>
  183. </div>
  184. {% endif %}
  185. {% endfor %}
  186. </div>
  187. {# Fragen Bereich 3: Ende #}
  188. {# Anzeige keine Suchtreffer #}
  189. <div class="c108-faq-no-results">
  190. <p>{{ 'faq.element.noresults'|trans }}</p>
  191. </div>
  192. {# Anzeige keine Suchtreffer: Ende #}
  193. </div>
  194. {# Fragen Bereich: Ende #}
  195. {% endblock %}
  196. <script>
  197. var faqElement = document.getElementById("{{ id }}-questionwrapper");
  198. var questionTabs = faqElement.getElementsByClassName("questiontab");
  199. var answerTabs = faqElement.getElementsByClassName("answertab");
  200. var sectionTitles = faqElement.getElementsByClassName("c108-faq-section-title");
  201. var noResultsText = faqElement.getElementsByClassName("c108-faq-no-results");
  202. var hideTitleSections = document.getElementsByClassName("c108-faq-section-hideable");
  203. var j;
  204. for (j = 0; j < questionTabs.length; j++) {
  205.   questionTabs[j].addEventListener("click", function() {
  206.     this.classList.toggle("active");
  207.     var answertab = this.nextElementSibling;
  208.     if (answertab.style.maxHeight) {
  209.       answertab.style.maxHeight = null;
  210.     } else {
  211.       answertab.style.maxHeight = answertab.scrollHeight + "px";
  212.     }
  213.   });
  214. }
  215. var searchField = document.getElementById("{{ id }}-searchField");
  216. searchField.addEventListener('input', function() {
  217.   var faqElement = document.getElementById("{{ id }}-questionwrapper");
  218.   var questionTabs = faqElement.getElementsByClassName("questiontab");
  219.   var answerTabs = faqElement.getElementsByClassName("answertab");
  220.   var sectionTitles = faqElement.getElementsByClassName("c108-faq-section-title");
  221.   var noResultsText = faqElement.getElementsByClassName("c108-faq-no-results");
  222.   // hide section title
  223.   for (var k = 0; k < sectionTitles.length; k++) {
  224.     sectionTitles[k].style['display'] = 'none';
  225.     sectionTitles[k].classList.remove("is-hidden");
  226.     sectionTitles[k].classList.add("is-shown");
  227.   }
  228.   // set all answer tabs to display block in case they were hidden because of title section hide
  229.   for (var o = 0; o < answerTabs.length; o++) {
  230.     answerTabs[o].style['display'] = 'block';
  231.   }
  232.   // get search input
  233.   var searchVal = this.value.toLowerCase();
  234.   var questionCounter = 0;
  235.   // check if search input matches content of answer or question
  236.   for (var i = 0; i < questionTabs.length; i++) {
  237.     if(!searchVal){
  238.       questionTabs[i].style['display'] = 'grid';
  239.       questionTabs[i].style['background-color'] = 'white';
  240.       questionTabs[i].querySelector('span').style['color'] = '#4a545b';
  241.       questionTabs[i].classList.remove('hide');
  242.       questionTabs[i].classList.remove('active');
  243.       answerTabs[i].style.maxHeight = null;
  244.       noResultsText[0].style['display'] = 'none';
  245.       // show section title
  246.       for (var k = 0; k < sectionTitles.length; k++) {
  247.         sectionTitles[k].style['display'] = 'grid';
  248.       }
  249.     }
  250.     else {
  251.       if (questionTabs[i].textContent.toLowerCase().indexOf(searchVal) > -1 || answerTabs[i].textContent.toLowerCase().indexOf(searchVal) > -1) {
  252.         questionTabs[i].style['display'] = 'grid';
  253.         questionTabs[i].style['background-color'] = '{{ c108faqhighlightcolor }}';
  254.         questionTabs[i].querySelector('span').style['color'] = 'white';
  255.         questionTabs[i].classList.add('hide');
  256.         questionTabs[i].classList.remove('active');
  257.         answerTabs[i].style.maxHeight = answerTabs[i].scrollHeight + "px";
  258.         // hide no results text
  259.         noResultsText[0].style['display'] = 'none';
  260.       }
  261.       else {
  262.         questionTabs[i].style['display'] = 'none';
  263.         questionTabs[i].style['background-color'] = 'white';
  264.         questionTabs[i].querySelector('span').style['color'] = '#4a545b';
  265.         questionTabs[i].classList.remove('hide');
  266.         answerTabs[i].style.maxHeight = null;
  267.         // show no results text
  268.         questionCounter += 1;
  269.         //noResultsText[0].style['display'] = 'block';
  270.       }
  271.     }
  272.   }
  273.   if(questionCounter == questionTabs.length){
  274.     noResultsText[0].style['display'] = 'block';
  275.   }
  276. });
  277. // add hideable feature
  278. var hideFaqSection = function() {
  279.   var currentTitleArea = event.target;
  280.   var allChildrenOfSection = currentTitleArea.parentNode.children;
  281.   
  282.   if(currentTitleArea.classList.contains("is-shown")){
  283.     for (var m = 0; m < allChildrenOfSection.length; m++) {
  284.       allChildrenOfSection[m].style.display = "none";
  285.     }
  286.     
  287.     currentTitleArea.style.display ="grid";
  288.     currentTitleArea.classList.add("is-hidden");
  289.     currentTitleArea.classList.remove("is-shown");
  290.     return;
  291.   }
  292.   if(currentTitleArea.classList.contains("is-hidden")){
  293.     for (var m = 0; m < allChildrenOfSection.length; m++) {
  294.       allChildrenOfSection[m].style.display = "grid";
  295.     }
  296.     
  297.     currentTitleArea.style.display ="grid";
  298.     currentTitleArea.classList.add("is-shown");
  299.     currentTitleArea.classList.remove("is-hidden");
  300.     
  301.     return;
  302.   }
  303. };
  304. // add hide event to title sections
  305. for (var l = 0; l < hideTitleSections.length; l++) {
  306.     hideTitleSections[l].addEventListener('click', hideFaqSection, false);
  307. }
  308. </script>
  309. </div>
  310. {% endblock %}