Current Path : /var/www/html/clients/e-nkama.ru/e-nkama_bitrix/bitrix/templates/nk/js/ |
Current File : /var/www/html/clients/e-nkama.ru/e-nkama_bitrix/bitrix/templates/nk/js/metshin-page.js |
$(document).ready(function() { contentHeight() $('.page-nav a, .header-menu a').click(function() { //при клике по навигации var ind = $(this).parent().index(); changeSlide(ind); }); $('.info-body .open-arw').click(function(e) { //клик по стрелке внизу contentInfo(e.type) }); $('.date-table').on('click', '.date-dot', function(e) { //клик по датам e.preventDefault(); if($(this).hasClass('disabled')) return false; //если неактивная дата var dot = $('.date-table .date-dot'), dis = $('.date-table .date-dot.disabled').length, ind = $(this).closest('td').index(), sl_ind = $(this).closest('td').index() - dis; dot.removeClass('active').eq(ind).addClass('active'); $('.date-section').removeClass('active').eq(sl_ind).addClass('active'); var sect = $('.info-body .info-section').eq(sl_ind); if(!sect.children('.body').length){ //если тело еще не грузили аяксом datesAjax(sl_ind); } }); $('.quote-slider').bxSlider({ minSlides: 1, maxSlides: 1, pager: false, adaptiveHeight: true, //slideWidth: 172, //slideMargin: 27, nextText: '', prevText: '' }); }); $(window).resize(function(e) { contentHeight() contentInfo() }); $(window).load(function(e) { scrollToSlide() contentInfo() }); function datesAjax(ind) { //аякс при клике на дату $.ajax({ url: '/nk-test/metshin-ajax.php', type: 'GET', data: { //num: ind, }, success: function(data) { //$('.info-section').eq(ind).append(data); //console.log(data); } }) } function contentInfo(event){ //показать/скрыть инфо на стр. метшина + ресайз контента на ней var head = $('.info-head'), lim = head.hasClass('active') ? 355 : 355 - head.outerHeight(), h = $(window).height() - lim, //~минус высота шапки + отступы и промежуточные блоки cont = $('.ch-height'); cont.css('max-height', h); if(event == 'click'){ var elements = $('.ch-height, .open-arw'), ul = $('.list-wrap'); elements.toggleClass('active'); ul.each(function(index, el) { var li = $(this).find('li.list:not(:first)'); ul.hasClass('active') ? li.slideDown(300) : li.slideUp(300); }); } } function scrollToSlide(){ //скролл к активному слайду при загрузке окна var body = $('html,body'), content = $('.bg-img'), content_a = $('.bg-img.active'), section = $('.info-section'), menu = $('.header-menu li a'), link = $('.page-nav li a'), ihead = $('.info-head'), ibody = $('.info-body'), hash = window.location.hash, ind, slide; if(hash == ''){ ind = content_a.index(); slide = content.eq(ind).position().top; body.scrollTop(slide); } else { var counter = 0; link.each(function() { if($(this).attr('href') == hash){ ind = $(this).parent().index(); slide = content.eq(ind).position().top; counter = 1; } }); if(counter != 1) slide = ind = 0; body.scrollTop(slide); content.removeClass('active').eq(ind).addClass('active'); section.removeClass('active').eq(ind).addClass('active'); menu.removeClass('active').eq(ind).addClass('active'); link.removeClass('active').eq(ind).addClass('active'); ibody.children('.info-section.active').children('.body').length ? ihead.addClass('active') : ihead.removeClass('active'); } } function contentHeight(){ //ресайз высоты контента + сохранение позиции слайда при ресайзе var h = $(window).height(), pos = $('.bg-img.active').position().top, bg = $('html,body'); $('.bg-img').each(function(){ $(this).css('height', h); }); bg.scrollTop(pos); } function changeSlide(num){ //листаем бэкграунд + контент var bg = $('html,body'), nav = $('.page-nav li a'), menu = $('.header-menu a'), cont = $('.bg-img'), cont_a = $('.bg-img.active'), ul_arw = $('.ch-height, .open-arw'), ul = $('.list-wrap'), info = $('.info-section'), ihead = $('.info-head'), ibody = $('.info-body'), position; if(status == 0){ status = 1; position = cont.eq(num).position().top; bg.animate({ 'scrollTop': position }, 600, function() { cont.removeClass('active').eq(num).addClass('active'); nav.removeClass('active').eq(num).addClass('active'); menu.removeClass('active').eq(num).addClass('active'); info.removeClass('active').eq(num).addClass('active'); ibody.children('.info-section.active').children('.body').length ? ihead.addClass('active') : ihead.removeClass('active'); ul_arw.removeClass('active'); ul.each(function(index, el) { $(this).find('li.list:not(:first)').slideUp(300); }); setTimeout(function(){ status = 0; }, 100); //отслеживаем окончание анимации через статус }); } }