{# 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 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'] %}
{% set currentLevelText = currentLevelNodeId['text'] %}
{% set currentLevelLinkType = currentLevelNodeId['link_type'] %}
onmouseover="
{# Replace the currently displayed feature 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 feature 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) %}
$('#{{containerId}} .feature_content').show();
{# Process title and description. Include the link if the menu node has it. #}
{% if currentLevelLinkType != 'no_link' %}
var start_link_tag = '';
{% else %}
var start_link_tag = '';
{% endif %}
var title = '{{currentLevelTitle|e('js')}}
';
{% 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 %}
{% else %}
{# If there is no title or description, hide the element. #}
$('.feature_content').hide();
{% endif %}
"
{% endmacro %}