jQuery(document).ready(function($){ //mobile navigation $('.m-nav').prepend('
Меню
'); $('.header').append('
Меню
'); $('.main').prepend(''); $('.slide-out-open').click(function() { $('body').addClass('js-nav'); $('.slide-out-close').addClass('rotate'); }); $('.slide-out-close').click(function() { $('body').removeClass('js-nav'); $(this).removeClass('rotate'); }); $('.menu-overlay').click(function() { $('body').removeClass('js-nav'); $('#slide-out-open').removeClass('slide-out-close').addClass('slide-out-open'); }); //header menu $('.header-menu > ul > li:has(ul)').append(''); $('.header-menu > ul > li:has(ul)').addClass('item_sub-menu'); $('.header-menu .menu-arrow').click(function() { var ul = $(this).prev(); if ( ul.is(':hidden') ) { ul.slideDown(450); $(this).addClass('active'); } else { ul.slideUp(450); $(this).removeClass('active'); } }); $('.header-menu > ul > li > ul > li.current-post-parent > .menu-arrow').addClass('active'); if ( $('.header-menu ul > li > ul >li').hasClass('current-menu-item') ) { $('.header-menu ul > li > ul > li.current-menu-item').parent().addClass('ul_block'); $('.header-menu ul > li > ul > li.current-menu-item').parent().next().addClass('active'); } if ( $('.header-menu ul > li > ul > li').hasClass('current-post-parent') ) { $('.header-menu ul > li > ul > li.current-post-parent').parent().addClass('ul_block'); $('.header-menu ul > li > ul > li.current-post-parent').parent().next().addClass('active'); } //Slider blocquotes home var sliderBl = $('#slider-bl'); if (sliderBl.length) { sliderBl.bxSlider({ adaptiveHeight: true, auto: true, pager: false }); } //Slider choose authors home if ($(window).width() <= '760') { var slider = $('#slider'); if (slider.length) { slider.bxSlider({ adaptiveHeight: true, auto: true, pager: false }); } } //more cats home $('.title-text__child_more').click(function() { if ( $(this).prev().is(':hidden') ) { $(this).prev().show(500); $(this).html('Скрыть'); $(this).addClass('active'); $(this).parent().addClass('active'); } else { $(this).prev().hide(500); $(this).html('Больше рубрик'); $(this).removeClass('active'); $(this).parent().removeClass('active'); } }); //cats children toggle $('.cat-children__title').click(function() { var child = $(this).next(); if ( child.is(':hidden') ) { child.slideDown(450); $(this).addClass('active'); } else { child.slideUp(450); $(this).removeClass('active'); } }); //category question posts toggle $('.cat-question__item-title').click(function() { var questionText = $(this).parent().next(); if ( questionText.is(':hidden') ) { questionText.slideDown(450); $(this).parent().addClass('active'); } else { questionText.slideUp(450); $(this).parent().removeClass('active'); } }); //category question posts author info toggle $('.cat-question__item-img img').click(function() { var authorInfo = $(this).next(); if ( authorInfo.is(':hidden') ) { authorInfo.slideDown(450); } else { authorInfo.slideUp(450); } }); $('.auth-info__close').click(function() { $(this).parent().hide(); }); //cat-home subcats toggle $('.title-text__toggle').click(function() { var subCats = $(this).next(); if ( subCats.is(':hidden') ) { subCats.slideDown(450); $(this).addClass('active'); } else { subCats.slideUp(450); $(this).removeClass('active'); } }); //Modal window in category question $('#open-form').click(function() { $('.modal-form').arcticmodal(); }); //Attribute start ol $('ol[start]').each(function() { var val = parseFloat($(this).attr("start")) - 1; $(this).css('counter-increment','li '+ val); }); //add scroll for tables on mobile versions $('.single table').wrap('
'); //Arrow up $('').appendTo('.footer .wrap').click(function() { $('html, body').animate({scrollTop: 0}, 700); }); var win = $(window); var up = $('#up'); win.on('scroll', function() { if ( win.scrollTop() > win.height() / 3 ) { up.fadeIn(); } else { up.fadeOut(); } }).scroll(); //Remove button load more $.ajaxSetup({complete: function() { $('.last_item').next('.more-box').remove(); }}); //pagination if ($('.more').length) { $('body').on('click', '.more:not(.loading)', function() { var more = $(this); var container = $(this).parent().prev('.ajax_pagination'); var defaultText = more.html(); more.addClass('loading').html( more.data('loading') ); var offset = more.data('offset'); var items = more.data('items'); var theme = more.data('theme'); var newposts = ''; var tax = ''; var tag = ''; var calc = ''; var question = ''; var video = ''; var money = ''; var search = ''; if( more.data('newposts') ) newposts = '&newposts=' + more.data('newposts'); if ( more.data('category') ) tax = '&category=' + more.data('category'); if ( more.data('tag') ) tag = '&tag=' + more.data('tag'); if ( more.data('calc') ) calc = '&calc=' + more.data('calc'); if ( more.data('question') ) question = '&question=' + more.data('question'); if ( more.data('video') ) video = '&video=' + more.data('video'); if ( more.data('money') ) money = '&money=' + more.data('money'); if ( more.data('search') ) search = '&search=' + more.data('search'); console.log(tax); $.ajax({ url: '/wp-content/themes/' + theme + '/ajax-posts.php?offset=' + offset + '&items=' + items + newposts + tax + tag + calc + question + video + money + search }).done(function(html) { container.after(html); more.data('offset', offset + items).removeClass('loading').html(defaultText); if ($.trim(html) === '') { more.remove(); } else { $('html, body').animate({scrollTop: $('.ajax_pagination:last').offset().top -100 }, 900); } }); }); } });