diff --git a/src/html/mod_menu/mainmenu.php b/src/html/mod_menu/mainmenu.php new file mode 100644 index 0000000..e664177 --- /dev/null +++ b/src/html/mod_menu/mainmenu.php @@ -0,0 +1,106 @@ + + * + * This file is part of a Moko Consulting project. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Main Menu - Mobile responsive collapsible dropdown menu override + * Bootstrap 5 responsive navbar with hamburger menu + */ + +defined('_JEXEC') or die; + +use Joomla\CMS\Helper\ModuleHelper; + +$id = ''; + +if ($tagId = $params->get('tag_id', '')) { + $id = ' id="' . $tagId . '"'; +} + +// Get module class suffix +$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx', ''), ENT_COMPAT, 'UTF-8'); + +// The menu class is deprecated. Use mod-menu instead +?> + diff --git a/src/html/mod_menu/mainmenu_component.php b/src/html/mod_menu/mainmenu_component.php new file mode 100644 index 0000000..dfcfa7f --- /dev/null +++ b/src/html/mod_menu/mainmenu_component.php @@ -0,0 +1,66 @@ + + * + * This file is part of a Moko Consulting project. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Main Menu - Component item layout + */ + +defined('_JEXEC') or die; + +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\HTML\HTMLHelper; + +$attributes = []; + +if ($item->anchor_title) { + $attributes['title'] = $item->anchor_title; +} + +if ($item->anchor_css) { + $attributes['class'] = $item->anchor_css; +} + +if ($item->anchor_rel) { + $attributes['rel'] = $item->anchor_rel; +} + +$linktype = $item->title; + +if ($item->menu_icon) { + // The link is an icon + if ($itemParams->get('menu_text', 1)) { + // If the link text is to be displayed, the icon is added with aria-hidden + $linktype = '' . $item->title; + } else { + // If the icon itself is the link, it needs a visually hidden text + $linktype = '' . $item->title . ''; + } +} + +if ($item->browserNav == 1) { + $attributes['target'] = '_blank'; + $attributes['rel'] = 'noopener noreferrer'; +} elseif ($item->browserNav == 2) { + $options = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $params->get('window_open'); + + $attributes['onclick'] = "window.open(this.href, 'targetWindow', '" . $options . "'); return false;"; +} + +// Add dropdown toggle for items with children +$linkClass = 'nav-link mod-menu-main__link'; +if ($item->deeper) { + $linkClass .= ' dropdown-toggle'; + $attributes['data-bs-toggle'] = 'dropdown'; + $attributes['role'] = 'button'; + $attributes['aria-expanded'] = 'false'; +} + +$attributes['class'] = $linkClass; + +echo HTMLHelper::_('link', OutputFilter::ampReplace(htmlspecialchars($item->flink, ENT_COMPAT, 'UTF-8', false)), $linktype, $attributes); diff --git a/src/html/mod_menu/mainmenu_heading.php b/src/html/mod_menu/mainmenu_heading.php new file mode 100644 index 0000000..990077e --- /dev/null +++ b/src/html/mod_menu/mainmenu_heading.php @@ -0,0 +1,39 @@ + + * + * This file is part of a Moko Consulting project. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Main Menu - Heading item layout + */ + +defined('_JEXEC') or die; + +$title = $item->anchor_title ? ' title="' . $item->anchor_title . '"' : ''; +$anchor_css = $item->anchor_css ?: ''; + +$linktype = $item->title; + +if ($item->menu_icon) { + // The link is an icon + if ($itemParams->get('menu_text', 1)) { + // If the link text is to be displayed, the icon is added with aria-hidden + $linktype = '' . $item->title; + } else { + // If the icon itself is the link, it needs a visually hidden text + $linktype = '' . $item->title . ''; + } +} + +// Add dropdown toggle for items with children +$headingClass = 'nav-link mod-menu-main__heading'; +if ($item->deeper) { + $headingClass .= ' dropdown-toggle'; +} + +?> +> diff --git a/src/html/mod_menu/mainmenu_separator.php b/src/html/mod_menu/mainmenu_separator.php new file mode 100644 index 0000000..2c0c587 --- /dev/null +++ b/src/html/mod_menu/mainmenu_separator.php @@ -0,0 +1,33 @@ + + * + * This file is part of a Moko Consulting project. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Main Menu - Separator item layout + */ + +defined('_JEXEC') or die; + +$title = $item->anchor_title ? ' title="' . $item->anchor_title . '"' : ''; +$anchor_css = $item->anchor_css ?: ''; + +$linktype = $item->title; + +if ($item->menu_icon) { + // The link is an icon + if ($itemParams->get('menu_text', 1)) { + // If the link text is to be displayed, the icon is added with aria-hidden + $linktype = '' . $item->title; + } else { + // If the icon itself is the link, it needs a visually hidden text + $linktype = '' . $item->title . ''; + } +} + +?> +> diff --git a/src/html/mod_menu/mainmenu_url.php b/src/html/mod_menu/mainmenu_url.php new file mode 100644 index 0000000..10b380b --- /dev/null +++ b/src/html/mod_menu/mainmenu_url.php @@ -0,0 +1,71 @@ + + * + * This file is part of a Moko Consulting project. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +/** + * Main Menu - URL item layout + */ + +defined('_JEXEC') or die; + +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\HTML\HTMLHelper; + +$attributes = []; + +if ($item->anchor_title) { + $attributes['title'] = $item->anchor_title; +} + +if ($item->anchor_css) { + $attributes['class'] = $item->anchor_css; +} + +if ($item->anchor_rel) { + $attributes['rel'] = $item->anchor_rel; +} + +$linktype = $item->title; + +if ($item->menu_icon) { + // The link is an icon + if ($itemParams->get('menu_text', 1)) { + // If the link text is to be displayed, the icon is added with aria-hidden + $linktype = '' . $item->title; + } else { + // If the icon itself is the link, it needs a visually hidden text + $linktype = '' . $item->title . ''; + } +} + +if ($item->browserNav == 1) { + $attributes['target'] = '_blank'; + $attributes['rel'] = 'noopener noreferrer'; +} elseif ($item->browserNav == 2) { + $options = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $params->get('window_open'); + + $attributes['onclick'] = "window.open(this.href, 'targetWindow', '" . $options . "'); return false;"; +} + +// Add dropdown toggle for items with children +$linkClass = 'nav-link mod-menu-main__link'; +if ($item->deeper) { + $linkClass .= ' dropdown-toggle'; + $attributes['data-bs-toggle'] = 'dropdown'; + $attributes['role'] = 'button'; + $attributes['aria-expanded'] = 'false'; +} + +// Merge existing class with our class +if (isset($attributes['class'])) { + $attributes['class'] .= ' ' . $linkClass; +} else { + $attributes['class'] = $linkClass; +} + +echo HTMLHelper::_('link', OutputFilter::ampReplace(htmlspecialchars($item->flink, ENT_COMPAT, 'UTF-8', false)), $linktype, $attributes);