{# N.b. see https://symfony.com/blog/better-white-space-control-in-twig-templates for what the -s and ~s are used for. #} {# Required to use Twig functions #} {%~ import _self as self %} {%~ macro featureImageOnClickEvent(menuNodeId) %} if (!window.zenarioA) return true; if (zenarioA.pageMode == 'menu') { zenarioAB.open('zenario_menu', {'mID':'{{menuNodeId}}'}, 'feature_image'); return false; } {%~ endmacro %} {%~ macro addOnMouseOver(containerId, currentLevelNodeId, topLevelNodeId, menuNodeHasOwnFeatureImage) %} {# This line must be included again if a function calls another function. #} {%~ import _self as self %} {# Define variables to avoid having to use quotes later #} {%~ set topLevelId = topLevelNodeId['id'] %} {%~ set topLevelTitle = topLevelNodeId['title'] %} {%~ set topLevelText = topLevelNodeId['text'] %} {%~ set currentLevelId = currentLevelNodeId['id'] %} {%~ set currentLevelImageLink = currentLevelNodeId['feature_image_link'] %} {%~ set currentLevelImageSrcset = currentLevelNodeId['Image_Srcset'] %} {%~ set currentLevelImageWidth = currentLevelNodeId['feature_image_width'] %} {%~ set currentLevelImageHeight = currentLevelNodeId['feature_image_height'] %} {%~ set currentLevelDestUrl = currentLevelNodeId['dest_url'] %} {%~ set currentLevelTitle = (currentLevelNodeId['title'] ? currentLevelNodeId['title'] : ' ') %} {%~ set currentLevelText = (currentLevelNodeId['text'] ? currentLevelNodeId['text'] : '

 

') %} {%~ set currentLevelLinkType = currentLevelNodeId['link_type'] %} onmouseover=" {# Title/description fallback logic: use the parent node details #} {%~ set title = (topLevelTitle ? topLevelTitle|e('js') : " ") %} {%~ set desc = (topLevelText ? topLevelText|e('js') : " ") %} $('#{{containerId}} .feature_title').html('

{{title}}

'); $('#{{containerId}} .feature_text').html('{{desc}}'); {# Replace the currently displayed featured image #} var el = zenario.get('{{containerId}}_node_id_{{topLevelId}}_feature_img'); if (el) { if (zenario.addBasePath('{{currentLevelImageLink}}') != el.src) { $('#' + el.id).show(); $('#' + el.id).stop().fadeTo(0, 0); el.src='{{currentLevelImageLink}}'; el.srcset='{{currentLevelImageSrcset}}'; el.width='{{currentLevelImageWidth}}'; el.height='{{currentLevelImageHeight}}'; $('#' + el.id).stop().fadeTo(600, 1); } {# Allow an admin to click on the image in Edit Menu mode to edit the current menu node properties. #} $('#' + el.id).removeAttr('onclick'); {%~ if menuNodeHasOwnFeatureImage %} $('#' + el.id).attr('onclick', '{{self.featureImageOnClickEvent(currentLevelId)|e('js')}}'); {%~ endif %} } {# Set the href of the featured image link to this menu node #} {%~ if currentLevelDestUrl %} $('#{{containerId}} .feature_image a').attr('href', '{{currentLevelDestUrl|e}}'); {%~ else %} $('#{{containerId}} .feature_image a').removeAttr('href'); {%~ endif %} {%~ if menuNodeHasOwnFeatureImage and (currentLevelTitle or currentLevelText) %} {# Process title and description. Include the link if the menu node has it. #} {%~ if currentLevelLinkType != 'no_link' %} var start_link_tag = ''; {%~ if (currentLevelLinkType != 'no_link') %} var end_link_tag = ''; {%~ else %} var end_link_tag = ''; {%~ endif %} $('#{{containerId}} .feature_title').html(start_link_tag + title + end_link_tag); $('#{{containerId}} .feature_text').html('{{currentLevelText|e}}'); {# Allow an admin to click on the title/text in Edit Menu mode to edit the current menu node properties. #} $('#{{containerId}} .feature_title').removeAttr('onclick'); $('#{{containerId}} .feature_text').removeAttr('onclick'); {%~ if currentLevelTitle %} $('#{{containerId}} .feature_title').attr('onclick', '{{self.featureImageOnClickEvent(currentLevelId)|e('js')}}'); {%~ endif %} {%~ if currentLevelText %} $('#{{containerId}} .feature_text').attr('onclick', '{{self.featureImageOnClickEvent(currentLevelId)|e('js')}}'); {%~ endif %} {%~ endif %} " {%~ endmacro %}
{%~ for node1 in nodes %} {%~ if not node1.is_admin_add_menu_item %}
{%~ endif %} {%~ endfor %}
{% do this.requireJsLib('zenario/libs/yarn/jquery-doubletaptogo/dist/jquery.dcd.doubletaptogo.min.js') %} {% do this.jQuery('#' ~ containerId ~ ' .level1.has_child > a', 'doubleTapToGo') %}