---vivi-file-Type-application/javascript---var el = { headerClass: $('.header').data('mobile') ? $('.header').data('mobile') : $('.header').attr('id'), mobileSearch: $('.header').data('search') ? $('.header-search-main').html() : $('.header-search-main').html(), nav: $('.header .nav').html(), } $(".header-custom").before("
") modalMobile(); controlModal(); $(window).on('resize', function(e){ setTimeout(function(){ if($(window).width() > 992) { $('.modal').modal('hide') } }, 1) }) function modalMobile() { var navContent, hotlineContent, dropMenuList; navContent = ''; navContent = navContent.replace('%headerClass%', el.headerClass).replace('%nav%', el.nav).replace('%mobileSearch%', el.mobileSearch); $('body').append(navContent); dropMenuList = $('#modal-mobile-nav .drop'); dropMenuList.each(function(e) { $(this).prepend(''); }) } function controlModal() { $('#modal-mobile-nav').on('show.bs.modal', function(e) { var id = $('.header').data('mobile'); $('body').addClass('modal-open-'+id); }); $('#modal-mobile-nav').on('hide.bs.modal', function(e) { var id = $('.header').data('mobile'); $('body').removeClass('modal-open-'+id); $(this).find('.btn-drop.active').click(); $('.navbar-toggle').removeClass('active'); }); $('.modal').on('show.bs.modal',function(e){ var id = $(this).attr('id'); setTimeout(function() { $('.modal-backdrop').last().addClass('backdrop-'+id); }, 10); }); $(document).on("click",".modal-backdrop", function() { $('.modal').modal('hide'); }) $('.modal-mobile-nav').on('click', '.btn-drop', function(e) { var parentEl, dropMenu, dropMenuHeight; parentEl = $(this).parent(); dropMenu = $(this).siblings('.drop-menu'); dropMenuHeight = dropMenu.prop('scrollHeight'); parentEl.siblings('li').find('.btn-drop.active').click(); $(this).toggleClass('active') // parentEl.toggleClass('active'); dropMenu.toggleClass('active'); dropMenu.css('height', dropMenuHeight+'px'); if(!$(this).hasClass('active')) { setTimeout(function() { dropMenu.css('height', 0); }, 1) } }) $('.drop-menu').on('transitionend webkitTransitionEnd oTransitionEnd', function(e) { if($(this).hasClass('active')) { $(this).css('height', 'auto'); } else { $(this).find('.btn-drop.active').click() } }) }