<?php
/********************************************************************
Product : Simple Responsive Menu
Date : 1 December 2023
Copyright : Les Arbres Design 2010-2023
Contact : https://www.lesarbresdesign.info
Licence : GNU General Public License
*********************************************************************/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\HTML\HTMLHelper;
require_once dirname(__FILE__).'/helper.php';
$list = ModSRMenuHelper::getList($params);
$base = ModSRMenuHelper::getBase($params);
$active = ModSRMenuHelper::getActive($params);
$default = ModSRMenuHelper::getDefault();
$active_id = $active->id;
$default_id = $default->id;
$path = $base->tree;
$showAll = $params->get('showAllChildren');
$class_sfx = htmlspecialchars($params->get('class_sfx',''));
$screen_width = $params->get('screen_width');
$div_styles = htmlspecialchars($params->get('div_styles',''));
$select_styles = htmlspecialchars($params->get('select_styles',''));
$showAll2 = $params->get('showAllChildren2');
$fixedText = $params->get('fixedText');
$showSeparators = $params->get('showSeparators');
$preventChosen = $params->get('preventChosen');
$hamburger = $params->get('hamburger');
if (empty($list))
return;
// render the desktop menu
$srm_mode = $params->get('srm_mode',0);
if ($srm_mode == 0)
{
echo '<div class="srm_large_menu">';
require ModuleHelper::getLayoutPath('mod_sr_menu', $params->get('layout', 'default'));
echo '</div>';
}
// render the mobile menu
// re-generate the item list if it's different for the responsive menu
if ($showAll != $showAll2)
{
$params->set('showAllChildren',$showAll2);
$list = ModSRMenuHelper::getList($params);
}
require ModuleHelper::getLayoutPath('mod_sr_menu', 'select_list');
// write the css that controls which menu is visible
$styles = "\n".' div.srm_position {display:none}';
if ($hamburger)
{
$styles .= "\n".' div.srm_position {width:2em;overflow:hidden}';
$styles .= "\n".' #srm_select_list {width:auto!important;max-width:none!important;border:none;-webkit-appearance:none}';
}
$styles .= "\n".' @media screen and (max-width:'.$screen_width.'px)';
$styles .= "\n".' {div.srm_position {display:block}';
$styles .= "\n".' div.srm_large_menu {display:none} }';
$style = "\n".'<style>'.$styles."\n </style>\n";
$document = Factory::getDocument();
$document->addCustomTag($style);
// if 'preventChosen' is set, add some Javascript to undo the modifications to the select list made by Chosen
if ($preventChosen)
{
HTMLHelper::_('jquery.framework');
$document->addScript(Uri::root(true).'/media/mod_sr_menu/js/mod_sr_menu.js');
}