/* * Implements the hamburger menu behaviour * * * @since 4.8 moved from avia.js to own file as some user request to customize this feature */ (function($) { "use strict"; $(document).ready( function() { $.avia_utilities = $.avia_utilities || {}; if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement ) { $.avia_utilities.isMobile = true; } else { $.avia_utilities.isMobile = false; } //activates the hamburger mobile menu avia_hamburger_menu(); }); $.avia_utilities = $.avia_utilities || {}; function avia_hamburger_menu() { var header = $('#header'), header_main = $('#main .av-logo-container'), //check if we got a top menu that is above the header menu = $('#avia-menu'), burger_wrap = $('.av-burger-menu-main a'), htmlEL = $('html').eq(0), overlay = $('
'), overlay_scroll = $('').appendTo(overlay), inner_overlay = $('').appendTo(overlay_scroll), bgColor = $('').appendTo(overlay), animating = false, first_level = {}, logo_container = $('.av-logo-container .inner-container'), menu_in_logo_container = logo_container.find('.main_menu'), cloneFirst = htmlEL.is('.html_av-submenu-display-click.html_av-submenu-clone, .html_av-submenu-display-hover.html_av-submenu-clone'), menu_generated = false, cloned_menu_cnt = 0; /** * Check for alternate mobile menu */ var alternate = $('#avia_alternate_menu'); if( alternate.length > 0 ) { menu = alternate; } var set_list_container_height = function() { //necessary for ios since the height is usually not 100% but 100% - menu bar which can be requested by window.innerHeight if($.avia_utilities.isMobile) { overlay_scroll.outerHeight(window.innerHeight); } }, create_list = function( items , append_to ) { if(!items) return; var list, link, current, subitems, megacolumns, sub_current, sub_current_list, new_li, new_ul; items.each(function() { current = $(this); subitems = current.find(' > .sub-menu > li'); //find sublists of a regular defined menu if( subitems.length == 0 ) { subitems = current.find(' > .children > li'); //find sublists of a fallback menu } megacolumns = current.find( '.avia_mega_div > .sub-menu > li.menu-item' ); // href = '#': we have a custom link that should not link to something - is also in use by megamenu for titles var cur_menu = current.find('>a'); var clone_events = true; if( cur_menu.length ) { if( cur_menu.get(0).hash == '#' || 'undefined' == typeof cur_menu.attr('href') || cur_menu.attr('href') == '#' ) { // eventhandler conflict 'click' by megamenu (returns false) - ignore all handlers if( subitems.length > 0 || megacolumns.length > 0 ) { clone_events = false; } } } link = cur_menu.clone(clone_events).attr('style',''); // megamenus can have '' as url in top menu - allow click event in burger if( 'undefined' == typeof cur_menu.attr('href') ) { link.attr( 'href', '#' ); } new_li = $('