(function($){ "use strict"; $(document).ready(function(){ if ($('body').length ) { $('body').fitVids(); } $('select').chosen(); $('.menu-touch').on('click',function(){ $(this).toggleClass('active'); $('.header-mainmenu .auliettalite-main-nav').slideToggle(); }); $('.auliettalite-main-menu').children().last().focusout( function() { $('.auliettalite-main-nav').removeAttr('style'); $('.menu-touch').removeClass('active'); } ); //Search $('.search-header .touch-search').on('click',function(){ $(this).parent().addClass('show-search'); }); $('.seach-box .btn-close').on('click',function(){ $(this).closest('.search-header').removeClass('show-search'); }); $('.search-header .searchform').children().last().focusout( function() { $('.search-header').removeClass('show-search'); }) // Back to top $('.backtotop').on('click', function(e){ e.preventDefault(); $('html, body').animate({scrollTop:0}, '300'); }); // Function Auliettalite navHeader(); auliettalite_main_menu(); $(document).scroll(function () { var scroll = $(this).scrollTop(); var topFixed = $('.header').outerHeight(); if (scroll > topFixed) { $('.header').addClass("header-fade"); } else { $('.header').removeClass("header-fade"); } if (scroll > 700) { $('.backtotop').show(); }else{ $('.backtotop').hide(); } }); }); //SHOW SUB MENU function auliettalite_main_menu() { //Add caret $('.auliettalite-main-menu li.menu-item-has-children > a,.auliettalite-main-menu li.page_item_has_children > a').wrap('
') $('.auliettalite-main-menu li.menu-item-has-children .wrap-linkmenu,.auliettalite-main-menu li.page_item_has_children .wrap-linkmenu').append( '
' ); //Click $('.auliettalite-main-menu li.menu-item-has-children > .wrap-linkmenu > .icon-dropdown,.auliettalite-main-menu li.page_item_has_children > .wrap-linkmenu > .icon-dropdown').on('click',function(e){ if( $(this).closest('li').hasClass('show-submenu') ){ $(this).closest('li').removeClass('show-submenu'); $(this).parent().removeClass('active'); } else { $(this).closest('ul').children('li').removeClass('show-submenu'); $(this).closest('ul').children('li').children('.active').removeClass('active'); $(this).closest('li').toggleClass('show-submenu'); $(this).parent().addClass('active'); } return false; }); } // NavHeader : Insert Logo function navHeader(){ var $header = $('.header'); if (!$header.length) { return; } var $navigation = $('.auliettalite-main-nav ul').first(), $navItems = $navigation.find('> li'), itemsNumber = $navItems.length, rtl = $('body').hasClass('rtl'), midIndex = parseInt(itemsNumber / 2 + .5 * rtl - .5), $midItem = $navItems.eq(midIndex), $logo = $header.find('.auliettalite-logo .inner-logo'), logoWidth, logoHeight, leftWidth = 0, rule = rtl ? 'marginLeft' : 'marginRight', rightWidth = 0; var recalc = function () { logoWidth = $logo.outerWidth(), leftWidth = 0, rightWidth = 0; for (var i = itemsNumber - 1; i >= 0; i--) { var itemWidth = $navItems.eq(i).outerWidth(); if (i > midIndex) { rightWidth += itemWidth; } else { leftWidth += itemWidth; } } var diff = leftWidth - rightWidth; if (rtl) { if (leftWidth > rightWidth) { $navigation.find('> li:first-child').css('marginRight', -diff); } else { $navigation.find('> li:last-child').css('marginLeft', diff); } } else { if (leftWidth > rightWidth) { $navigation.find('> li:last-child').css('marginRight', diff); } else { $navigation.find('> li:first-child').css('marginLeft', -diff); } } $midItem.css(rule, logoWidth + 30); logoHeight = $logo.outerHeight(); $('.header-main').css('min-height',logoHeight + 'px'); }; $logo.find('.logo-img').imagesLoaded(function () { recalc(); }); $(window).on('resize', recalc() ); } })(jQuery);