function uniFlyMenu() { if($('#unicheckout').length) return; const prodPage = uniJsVars.fly_menu.product && $('#product').length; const init = () => { $('#fly-menu').remove(); let windowWidth = $(window).width(), breakpoint = 992, desktop_menu = (uniJsVars.fly_menu.desktop && windowWidth > breakpoint) ? true : false, mobile_menu = (uniJsVars.fly_menu.mobile != 0 && windowWidth <= breakpoint) ? true : false; if(!desktop_menu && !mobile_menu) return; const new_class = (mobile_menu && uniJsVars.fly_menu.mobile == 'bottom') ? 'bottom show' : '', show_label = mobile_menu && uniJsVars.fly_menu.label ? true : false; let html = '
'; html += '
'; if(desktop_menu) { if(prodPage) { html += '
'; html += '
'+$('h1.heading').text()+'
'; html += '
'+$('.product-page__price').html()+'
'; const btn = $('#product').find('.product-page__add-to-cart'); if(btn.length) html += ''; html += '
'; } else { html += '
'; html += ''; } html += '
'+$('.header-phones__main').html()+'
'; } if(mobile_menu){ if(uniJsVars.fly_menu.home) { html += '
'; html += ''; if(show_label) html += '
'+uniJsVars.fly_menu.text_home+'
'; html += '
'; } html += '
'; html += ''; if(show_label) html += '
'+uniJsVars.fly_menu.text_catalog+'
'; html += '
'; html += '
'; html += ''; if(show_label) html += '
'+uniJsVars.fly_menu.text_search+'
'; html += $('header #search').html(); html += '
'; } let show_phone = 0; if(mobile_menu && show_phone){ html += '
'; html += ''; html += ''; html += '
'; } else { html += ''; } if(uniJsVars.fly_menu.wishlist == 1 && desktop_menu || uniJsVars.fly_menu.wishlist == 2 && mobile_menu || uniJsVars.fly_menu.wishlist == 3){ html += '
'; html += ''; html += ''+$('.top-menu__wishlist-total').html()+''; if(show_label) html += '
'+uniJsVars.fly_menu.text_wishlist+'
'; html += '
'; } if(uniJsVars.fly_menu.compare == 1 && desktop_menu || uniJsVars.fly_menu.compare == 2 && mobile_menu || uniJsVars.fly_menu.compare == 3){ html += '
'; html += ''; html += ''+$('.top-menu__compare-total').html()+''; if(show_label) html += '
'+uniJsVars.fly_menu.text_compare+'
'; html += '
'; } html += '
'; html += ''; html += ''+$('header .header-cart__total-items').text()+''; if(show_label) html += '
'+uniJsVars.fly_menu.text_cart+'
'; html += '
'; html += '
'; if(!$('#fly-menu').length) { $('html body').append(html); const menuBlock = $('.fly-menu__block'); menuBlock.on('click', function() { const $this = $(this); menuBlock.toggleClass('show').not($this).removeClass('show'); if(mobile_menu) { $('html').removeClass('scroll-disabled'); if(($this.hasClass('fly-menu__search-m') || $this.hasClass('fly-menu__account')) && !$('.fly-menu-backdrop').length) { $('.fly-menu').before('
'); } if($this.hasClass('show')) { $('html').addClass('scroll-disabled'); if($this.hasClass('fly-menu__menu-m')) { $('.menu-wrapper').addClass('show'); } if($this.hasClass('fly-menu__search-m')) { $('.fly-menu__search-m .form-control').focus(); } } else { $('.fly-menu-backdrop').remove(); } const account_ul = $('.fly-menu__account-dropdown'); if(account_ul.offset().left + account_ul.outerWidth() > $(window).width()) { account_ul.css('margin-left', -((account_ul.offset().left + account_ul.outerWidth()) - $(window).width()) - 1) } } }); uniSearch.clearBtn(); $('.fly-menu__account li').on('click', function() { $(this).closest('.fly-menu__block').removeClass('show'); }); $('body').on('hide.bs.modal', '.modal', () => { $('.fly-menu-backdrop').click(); }); $('html body').on('click', '.fly-menu-backdrop, .menu-close, main, footer', () => { $('html').removeClass('scroll-disabled'); menuBlock.removeClass('show'); $('.fly-menu-backdrop').remove(); }); if(desktop_menu) { if(prodPage) { $(document).on('change', '#product input, #product select', () => { setTimeout(() => { $('.fly-menu__product-price').html($('.product-page__price').html()); }, 350); }); $('.fly-menu__product-btn').css('cursor', 'pointer').click(() => { $('#button-cart').click(); }); $('.fly-menu__product-name').mouseover(function() { var boxWidth = $(this).width(); $text = $('.fly-menu__product-name span'); $textWidth = $('.fly-menu__product-name span').width(); if ($textWidth > boxWidth) { $($text).animate({left: -(($textWidth+20) - boxWidth)}, 500); } }).mouseout(function() { $($text).stop().animate({left: 0}, 500); }); } else { $('.fly-menu__search').css('margin-left', -($('.fly-menu__menu').width() - $('.fly-menu .menu__header').outerWidth())); uniMenuAim(); } } } }; init(); let windowWidth = $(window).width(); $(window).resize(function() { if($(this).width() != windowWidth) { windowWidth = $(this).width(); init(); } }); $(window).scroll(function(){ if($(this).scrollTop() > 200) { $('#fly-menu').addClass('show'); } else { $('#fly-menu, #fly-menu .row > div').removeClass('show'); } }); } $(function() { //setTimeout(() => { uniFlyMenu(); //}, 550); });