vendor/store.shopware.com/c108hotspots/src/Resources/views/storefront/element/cms-element-hotspots.html.twig line 1

Open in your IDE?
  1. {% block element_hotspots %}
  2. {% set id = element.id %}
  3. {% set allMarkers = element.data.allMarkers %}
  4. {% set c108hdesign = element.config.c108hdesign.value %}
  5. {% set c108hnrhotspots = element.config.c108hnrhotspots.value %}
  6. {% set currMediaId = element.config.media.value %}
  7. {% set currMediaCollection = searchMedia([currMediaId], context.context) %}
  8. {% set currMediaObject = currMediaCollection.get(currMediaId) %}
  9. {% set currImgPath = currMediaObject.url %}
  10. {% set currImgAlt = currMediaObject.translated.alt %}
  11. {% set currImgTitle = currMediaObject.translated.title  %}
  12. {% set c108hhighlightcol = element.config.c108hhighlightcol.value %}
  13. {% set c108hmobileimagebool = element.config.c108hmobileimagebool.value|default(false) %}
  14. {% set c108htabletimagebool = element.config.c108htabletimagebool.value|default(false) %}
  15. {% set c108hmobileimageurl = element.config.c108hmobileimageurl.value|default('') %}
  16. {% set c108htabletimageurl = element.config.c108htabletimageurl.value|default('') %}
  17. {% set c108hlazyloadingattributebool = element.config.c108hlazyloadingattributebool.value|default(false) %}
  18. {% set c108huseeditorbool = element.config.c108huseeditorbool.value|default(false) %}
  19. {% set c108husemaxheightbool = element.config.c108husemaxheightbool.value|default(false) %}
  20. {% set c108hfrontendlabelsbool = element.config.c108hfrontendlabelsbool.value|default(false) %}
  21. {% set c108hindividualcolorsbool = element.config.c108hindividualcolorsbool.value|default(false) %}
  22. {% set c108hcloseonclickedoutsidebool = element.config.c108hcloseonclickedoutsidebool.value|default(false) %}
  23. {% if c108hfrontendlabelsbool %}
  24. <style>
  25. div[data-cms-element-id="{{ id }}"] .hfi-frontend-label {
  26.   background-color: rgba(255, 255, 355, 0.85);
  27.   width: 120px;
  28.   display: inline-block;
  29.   text-align: center;
  30.   font-size: 11px;
  31.   padding: 4px;
  32.   font-weight: 600;
  33.   box-shadow: 0 4px 4px rgb(0 0 0 / 30%);
  34.   pointer-events: none;
  35.   position: absolute;
  36.   left: -40px;
  37.   right: 0;
  38.   top: 50px;
  39.   word-break: break-all;
  40. }
  41. div[data-cms-element-id="{{ id }}"] .einfach .hfi-frontend-label {
  42.   left: -50px;
  43.   top: 30px;
  44. }
  45. @media screen and (max-width: 767px) {
  46.   div[data-cms-element-id="{{ id }}"] .hfi-frontend-label {
  47.     display:none;
  48.   }
  49. }
  50. </style>
  51. {% endif %}
  52. <div id="hfi-wrapper-{{ id }}" data-cms-element-id="{{ id }}" class="c108-hfi-wrapper {{ c108hdesign }}">
  53. <div class="c108-hfi-inner">
  54. {# image #}
  55. <picture>
  56. <source media="(min-width: 1280px)" srcset="{{ currImgPath }}">
  57. {% if c108htabletimagebool %}
  58. <source media="(min-width: 768px) and (max-width: 1279px)" srcset="{{ c108htabletimageurl }}">
  59. {% endif %}
  60. {% if c108hmobileimagebool %}
  61. <source media="(max-width: 767px)" srcset="{{ c108hmobileimageurl }}">
  62. {% endif %}
  63. <img class="c108-hfi-bgimg" src="{{ currImgPath }}" alt={% if currImgAlt %}"{{ currImgAlt }}"{% else %}"Animated markings image"{% endif %} {% if currImgTitle %}title="{{ currImgTitle }}"{% else %}title="Animated markings image"{% endif %}{% if c108hlazyloadingattributebool %} loading="lazy"{% endif %}>
  64. </picture>
  65. {# marker #}
  66. {% for marker in allMarkers %}
  67. <div id="{{ id }}-c108-hfi-element-{{ loop.index }}" style="top: {{ marker.ypos.value }}%; left: {{ marker.xpos.value }}%;" class="c108-hfi-element {{ marker.hoverpos.value }}">
  68. <div class="c108-hfi-element-inner" style="position:relative;">
  69. <div data-element-id="{{ id }}" data-explanation-state="closed" class="c108-hfi-marker c108-hfi-marker-{{ id }}" onmouseover="showExplanation('{{ id }}', '{{ loop.index }}')" {% if c108hindividualcolorsbool and marker.color.value %}style="background-color:{{ marker.color.value }}"{% else %}style="background-color:{{ c108hhighlightcol }}"{% endif %}>
  70. {% if c108hfrontendlabelsbool %}<span class="hfi-frontend-label" data-label-state="visible">{{ marker.title.value|u.truncate(50, '...') }}</span>{% endif %}
  71. <span class="hfi-num">{{ loop.index }}</span>
  72. <span class="hfi-plus">+</span>
  73. </div>
  74. {# desktop #}
  75. <div id="{{ id }}-explanation-{{ loop.index }}" class="c108-hfi-explanation c108-hfi-explanation-d-{{ id }} desktop{% if c108husemaxheightbool %} max-height-enabled{% endif %}">
  76. <span class="c108-hfi-explanation-close" onclick="closeExplanation()">×</span>
  77. {% if c108huseeditorbool %}
  78. <div>{% autoescape %}{{ marker.texteditorcontent.value|default('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')|raw }}{% endautoescape %}</div>
  79. {% else %}
  80. <span class="expl-title">{{ marker.title.value }}</span>
  81. <p>{{ marker.description.value }}</p>
  82. {% if marker.linkbool.value %}
  83. {% if marker.linkinternal.value == true %}
  84. <a style="color:{{ c108hhighlightcol }};" href="{{ marker.linkurl.value }}" title="{{ marker.linktitle.value }}">{{ marker.linktitle.value }}</a>
  85. {% else %}
  86. <a style="color:{{ c108hhighlightcol }};" href="{{ marker.linkurl.value }}" rel="noopener" target="_blank" title="{{ marker.linktitle.value }}">{{marker.linktitle.value }}</a>
  87. {% endif %}
  88. {% endif %}
  89. {% endif %}
  90. </div>
  91. </div>
  92. </div>
  93. {% endfor %}
  94. {# mobile explanation box #}
  95. <div class="hfi-mobile-explanation-box">
  96. {% for marker in allMarkers %}
  97. <div id="explanation-mobile-{{ loop.index }}-{{ id }}" class="c108-hfi-explanation c108-hfi-explanation-m-{{ id }} mobile{% if c108husemaxheightbool %} max-height-enabled{% endif %}">
  98. <span class="c108-hfi-explanation-close" onclick="closeExplanation()">×</span>
  99. {% if c108huseeditorbool %}
  100. <div>{% autoescape %}{{ marker.texteditorcontent.value|default('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')|raw }}{% endautoescape %}</div>
  101. {% else %}
  102. <span class="expl-title">{{ marker.title.value }}</span>
  103. <p>{{ marker.description.value }}</p>
  104. {% if marker.linkbool.value %}
  105. {% if marker.linkinternal.value == true %}
  106. <a style="color:{{ c108hhighlightcol }};" href="{{ marker.linkurl.value }}" title="{{ marker.linktitle.value }}">{{ marker.linktitle.value }}</a>
  107. {% else %}
  108. <a style="color:{{ c108hhighlightcol }};" href="{{ marker.linkurl.value }}" rel="noopener" target="_blank" title="{{ marker.linktitle.value }}">{{ marker.linktitle.value }}</a>
  109. {% endif %}
  110. {% endif %}
  111. {% endif %}
  112. </div>
  113. {% endfor %}
  114. </div>
  115. </div>
  116. </div>
  117. <script>
  118. function showExplanation(elementid, markernr){
  119.   var currentHotspotsElement = document.getElementById("hfi-wrapper-" + elementid);
  120.   var openExplanations = currentHotspotsElement.querySelectorAll(`[data-explanation-state="opened"]`);
  121.   var hiddenFrontendLabels = currentHotspotsElement.querySelectorAll(`[data-label-state="hidden"]`);
  122.   // hide opened explanations
  123.   for (var i = 0; i < openExplanations.length; i++) {
  124.     var currExplanation = openExplanations[i];
  125.     if (currExplanation !== '' && currExplanation){
  126.       currExplanation.setAttribute("data-explanation-state", "closed");
  127.       currExplanation.style.opacity = "0";
  128.       currExplanation.style.zIndex = "0";
  129.       currExplanation.style.pointerEvents = "none";
  130.       currExplanation.parentElement.style.zIndex = "1";
  131.       currExplanation.parentElement.parentElement.style.zIndex = "1";
  132.     }
  133.   }
  134.   // show hidden frontend labels
  135.   for (var k = 0; k < hiddenFrontendLabels.length; k++) {
  136.     var currLabel = hiddenFrontendLabels[k];
  137.     if (currLabel !== '' && currLabel){
  138.       currLabel.style.visibility = "visible";
  139.       currLabel.setAttribute("data-label-state", "visible");
  140.     }
  141.   }
  142.   // show explanation
  143.   var explanationDesktop = event.target.nextElementSibling;
  144.   var hotspotFrontendLabel = event.target.firstElementChild;
  145.   // hide label
  146.   if(hotspotFrontendLabel && hotspotFrontendLabel.classList.contains("hfi-frontend-label")){
  147.     hotspotFrontendLabel.style.visibility = "hidden";
  148.     hotspotFrontendLabel.setAttribute("data-label-state", "hidden");
  149.   }
  150.   explanationDesktop.setAttribute("data-explanation-state", "opened");
  151.   explanationDesktop.style.opacity = "1";
  152.   explanationDesktop.style.zIndex = "1000";
  153.   explanationDesktop.style.pointerEvents = "visible";
  154.   explanationDesktop.parentElement.style.zIndex = "1000";
  155.   explanationDesktop.parentElement.parentElement.style.zIndex = "1000";
  156.   var explanationMobile = currentHotspotsElement.querySelector("#explanation-mobile-" + markernr + "-" + elementid);
  157.   explanationMobile.setAttribute("data-explanation-state", "opened");
  158.   explanationMobile.style.opacity = "1";
  159.   explanationMobile.style.zIndex = "1000";
  160.   explanationMobile.style.pointerEvents = "visible";
  161.   explanationMobile.parentElement.style.zIndex = "1000";
  162. }
  163. function closeExplanation() {
  164.   var explanation = event.target.parentElement;
  165.   
  166.   if(event.target.parentElement.previousElementSibling && event.target.parentElement.previousElementSibling.firstElementChild){
  167.     var hotspotFrontendLabel = event.target.parentElement.previousElementSibling.firstElementChild;
  168.   }
  169.   
  170.   if(hotspotFrontendLabel && hotspotFrontendLabel.classList.contains("hfi-frontend-label")){
  171.     hotspotFrontendLabel.style.visibility = "visible";
  172.     hotspotFrontendLabel.setAttribute("data-label-state", "visible");
  173.   }
  174.   explanation.style.opacity = "0";
  175.   explanation.style.zIndex = "0";
  176.   explanation.style.pointerEvents = "none";
  177.   explanation.parentElement.style.zIndex = "1";
  178.   explanation.parentElement.parentElement.style.zIndex = "1";
  179.   explanation.setAttribute("data-explanation-state", "closed");
  180. }
  181. </script>
  182. {% if c108hcloseonclickedoutsidebool %}
  183. <script>
  184. document.addEventListener('click', function(event) {
  185.     var isClickInsideExplanation = event.target.closest('[data-explanation-state="opened"]');
  186.     if (!isClickInsideExplanation) {
  187.         var openedExplanations = document.querySelectorAll('[data-explanation-state="opened"]');
  188.         openedExplanations.forEach(function(openedExplanation) {
  189.             if (openedExplanation.previousElementSibling && openedExplanation.previousElementSibling.firstElementChild) {
  190.                 var hotspotFrontendLabel = openedExplanation.previousElementSibling.firstElementChild;
  191.                 if (hotspotFrontendLabel && hotspotFrontendLabel.classList.contains("hfi-frontend-label")) {
  192.                     hotspotFrontendLabel.style.visibility = "visible";
  193.                     hotspotFrontendLabel.setAttribute("data-label-state", "visible");
  194.                 }
  195.             }
  196.             openedExplanation.style.opacity = "0";
  197.             openedExplanation.style.zIndex = "0";
  198.             openedExplanation.style.pointerEvents = "none";
  199.             openedExplanation.parentElement.style.zIndex = "1";
  200.             openedExplanation.parentElement.parentElement.style.zIndex = "1";
  201.             openedExplanation.setAttribute("data-explanation-state", "closed");
  202.         });
  203.     }
  204. });
  205. </script>
  206. {% endif %}
  207. {% endblock %}