Jump to content
  • 0

Поправить файл main.js на сайте html


Jokerrs
 Share

Question

Сайт Html. Нужно поправить main.js файл, чтобы не дублировался домен в url, чтобы отображались кнопки перевода с русского на английский и наоборот, чтобы была нормальная поддержка русской и английской версии сайта. Вроде как js определяет версию сайта и показывает соответствующие кнопки для перехода на другую

Сайт

Скрытый текст

main.js

var _b_phone = 490,
    _b_tablet = 780.
    _b_desktop = 1024,
    _isAdvantagesSlicked = false;

$(document).ready(function () {
    $('.menu__burger').click(function() {
        $('.menu__overlay').show();
        $('.menu__popup').addClass('menu__popup--shown');
    });

    $('.menu__overlay').click(function() {
        $('.menu__popup').removeClass('menu__popup--shown');
        $(this).hide();
    });

    slickify();
    parallax();
    setupTabs();

    $(window).resize(function(){
        slickify();   
    });

    setupInputs();
    setupForms();
    setupLanguage();
});

function setupTabs() {
    $('.synopsis__tabs__tab').click(function() {
        if (!$(this).hasClass('synopsis__tabs__tab--active')) {
                $(this).addClass('synopsis__tabs__tab--active');
            if ($(this).index() == 0) {
                $('.synopsis__tabs__tab').eq(1).removeClass('synopsis__tabs__tab--active');
                $('.faq').hide();
                $('.reviews').show();
                $('.reviews__content').slick('unslick');
                slickReviews();
            }
            if ($(this).index() == 1) {
                $('.synopsis__tabs__tab').eq(0).removeClass('synopsis__tabs__tab--active');
                $('.reviews').hide();
                $('.faq').show();
            }
        }
    });

    $('.faq__item__header').click(function() {
        if ($(this).hasClass('faq__item__header--active')) {
            $(this).removeClass('faq__item__header--active');
            $(this).parent().find('.faq__item__content').hide();
        } else {
            $(this).addClass('faq__item__header--active');
            $(this).parent().find('.faq__item__content').show();
        }
    });
}

function parallax() {
    var $windowWidth = $(window).width();
    if ($windowWidth > _b_desktop) { 
        var movementStrength = 25;
        var height = movementStrength / $(window).height();
        var width = movementStrength / $(window).width();
        $('body').mousemove(function(e){
            var pageX = e.pageX - ($(window).width() / 2);
            var pageY = e.pageY - $(this).scrollTop() - ($(window).height() / 2);
            var newvalueX = width * pageX * -1 - movementStrength * 2;
            var newvalueY = height * pageY * -1 - movementStrength * 0.5;
            $('.offer').css("background-position", newvalueX + "px "+ newvalueY + "px");
        });
    }  
}

function slickify(){
    var $windowWidth = $(window).width();
    if ($windowWidth <= _b_phone) {
        if (!_isAdvantagesSlicked) {
           $('.advantages__cols').slick({
                autoplay: true,
                autoplaySpeed: 4000,
                delay: 5000,
                speed: 700,
                arrows: false,
                dots: true,
                centerMode: true,
                centerPadding: '80px',
                slidesToShow: 1,
                responsive: [
                    {
                        breakpoint: _b_phone,
                        settings: {
                            centerPadding: '0'
                        }
                    }
                ]
            }); 
            _isAdvantagesSlicked = true;
        }
    } else {
        if (_isAdvantagesSlicked) {
            $('.advantages__cols').slick('unslick');
            _isAdvantagesSlicked = false;
        }
    }

    $('.cases__carousel__content').on('init', function(){
        var url = window.location.href;

        if (url.indexOf("/en/") !== -1) {
            $('.cases__carousel__item').each(function() {
                var src = $(this).find('img').attr('src');
                var newSrc = src.replace("/en/", '');
                $(this).find('img').attr('src', newSrc);
            });
        }
    });

    $('.cases__carousel__content').slick({
        autoplay: true,
        autoplaySpeed: 2000,
        speed: 700,
        centerMode: true,
        centerPadding: '290px',
        slidesToShow: 1,
        prevArrow: '.cases__arrow--left',
        nextArrow: '.cases__arrow--right',
        responsive: [
            {
                breakpoint: _b_tablet,
                settings: {
                    centerPadding: '0'
                }
            }
        ]
    }); 

    slickReviews();
}

function slickReviews() {
    $('.reviews__content').slick({
        autoplay: true,
        autoplaySpeed: 4000,
        speed: 700,
        rows: 2,
        slidesToShow: 2,
        prevArrow: '.reviews__arrow--left',
        nextArrow: '.reviews__arrow--right',
        responsive: [
            {
                breakpoint: _b_desktop,
                settings: {
                    centerMode: true,
                    slidesToShow: 1
                }
            },
            {
                breakpoint: _b_tablet,
                settings: {
                    centerMode: true,
                    slidesToShow: 1,
                    centerPadding: '-50px'
                }
            },
            {
                breakpoint: _b_phone,
                settings: {
                    centerMode: true,
                    slidesToShow: 1,
                    centerPadding: '-80px'
                }
            }
        ]
    });
}

function setupInputs() {
    $('.coop__form__file__input').on('change', function() {
        $(this).prev('.coop__form__file__msg').html($(this).val().split('\\').pop());
    });
}

function setupForms() {
    $('form').formify(function() {
        alert('Спасибо. С вами свяжутся в ближайшее время.')
    });
}

function setupLanguage() {
    var locLang = (navigator.language) ? navigator.language : navigator.userLanguage;
    var url = window.location.href;
    var newUrl = 'https://boostinghouse.com/';
    
    if (locLang !== 'ru' && url.indexOf("/en") == -1) {
        var subUrl = url.replace(newUrl, '');
        newUrl += '/en/' + subUrl;
        window.location.href = newUrl;
    }

    if (locLang == 'ru') {
        $('.lang-switch').css('visibility', 'visible');
        $('#lang-flag, #lang-ru, #lang-toggle').show();
    }
}

function clamp(num, min, max) {
    if (!num) return 0;
    return num <= min ? min : num >= max ? max : num;
}

 

Отстутствует выбор языка.png

Отстутствует.png

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy