diff --git a/bin/MegaMenu.js b/bin/MegaMenu.js index 1fe36bf9327fdbccd146af741339c766bb6b0134..ef7fcf60ac60ec6fa7eed377ac69bdec83aabe1a 100644 --- a/bin/MegaMenu.js +++ b/bin/MegaMenu.js @@ -125,7 +125,7 @@ define('package/quiqqer/menu/bin/MegaMenu', [ var SlideNode = document.getElement('[data-qui="package/quiqqer/menu/bin/SlideOut"]'), SlideOut = QUI.Controls.getById(SlideNode.get('data-quiid')), MobileMenu = this.getElm().getElement('.quiqqer-menu-megaMenu-mobile'); - + if (!MobileMenu) { return; } @@ -167,13 +167,59 @@ define('package/quiqqer/menu/bin/MegaMenu', [ this.$Menu.set('html', Menu.get('html')); + let getTarget = function (Link) { + let href = Link.href; + + if (href.indexOf('#') === -1) { + return false; + } + + let targetString = href.substring(href.indexOf('#') + 1); + + if (targetString.length < 1) { + return false; + } + + let TargetElm = document.getElementById(targetString); + + if (!TargetElm) { + return false; + } + + return TargetElm; + }; + + let clickEvent = function (Target, offset) { + new Fx.Scroll(window, { + offset: { + y: -offset + } + }).toElement(Target); + }; + this.$Menu.getElements('a').addEvent('click', function (event) { var Link = event.target; - if (Link.nodeName != 'A') { + + if (Link.nodeName !== 'A') { Link = Link.getParent('a'); } event.stop(); + + let TargetElm = getTarget(Link); + console.log("click auf A"); + if (TargetElm) { + console.log("target gefunden, scrollen"); + let offset = Link.get('data-qui-offset'); + + if (!offset) { + offset = window.SCROLL_OFFSET ? window.SCROLL_OFFSET : 0; + } + + clickEvent(TargetElm, offset); + return; + } + window.location = Link.get('href'); }); diff --git a/src/QUI/Menu/MegaMenu.Independent.html b/src/QUI/Menu/MegaMenu.Independent.html index dc25058c009e7c73b8d1f6fbfc499ac047902109..cb3b549a63b73bfed359c077b666d45926a4e29f 100644 --- a/src/QUI/Menu/MegaMenu.Independent.html +++ b/src/QUI/Menu/MegaMenu.Independent.html @@ -40,7 +40,11 @@ {if count($subchildren)} <span class="fa fa-angle-down"></span> {/if} - </span> + </span> + {/if} + + {if $showMenu && $Child->getMenuType() && $Child->getMenuType() !== ''} + {assign var=usedControl value=$this->getMenuControl($Child->getMenuType())} {/if} {if count($subchildren) && $usedControl}