(function ($) { var isMobile = false; $(document).ready(function () { $(window).resize(sizeAdjust); $("#hamburger").on("click", toggleMenu); $(window).on("click", clickOutSide); $(window).on("scroll", scrollNavbar); scrollNavbar(); sizeAdjust(); // on click comparison if ($("#comparison_title").length) { $("#comparison").removeAttr("href"); $("#comparison").on("click", function (e) { e.preventDefault(); $("html,body").animate({ scrollTop: $("#comparison_title").offset().top - 70 + "px" }, 1000, "swing" ); }); } $('[data-toggle="popover"]').popover({ trigger: "hover" }); }); function scrollNavbar() { if ($(this).scrollTop() > 0) $("#navbar-main").hide("slow"); else $("#navbar-main").show("slow") } function clickOutSide(e) { if ($("#hamburger").hasClass("active") && !$(e.target).is("#menu_open") && !$(e.target).is("#hamburger") && !$(e.target).is("#hamburger>hr")) closeMenu(); } function closeMenu() { $("#hamburger").removeClass("active"); $("#menu_open").removeClass("open_menu"); $("body").removeClass("no_scroll"); $("#menu_overlay").removeClass("active"); } function toggleMenu() { $("#hamburger").toggleClass("active"); $("#menu_open").toggleClass("open_menu"); $("body").toggleClass("no_scroll"); $("#menu_overlay").toggleClass("active"); } function sizeAdjust() { closeMenu(); if (window.innerWidth > 768 && isMobile) { isMobile = false; scrollNavbar(); $(window).on("scroll", scrollNavbar); } else if (window.innerWidth <= 768 && !isMobile) { isMobile = true; $(window).off("scroll", scrollNavbar); $("#navbar-main").addClass("navbar-move"); } } var isTableMobile = false; var speed = 400; $(document).ready(function () { $(".answers_questions li.question").on("click", function () { $(this) .next() .slideToggle(speed) .siblings(".answers_questions li.answer") .slideUp(speed); }); // ------------- guide carusel ------------- $(".guide_carusel .glyphicon:nth-of-type(2)").on("click", function () { $(".read_about:nth-of-type(1)").appendTo(".guide_caruse_content"); }); $(".guide_carusel .glyphicon:nth-of-type(1)").on("click", function () { $(".read_about:nth-last-of-type(1)").prependTo(".guide_caruse_content"); }); // ------------- faq carusel ------------- $("#right").on("click", function () { $(".questions .question:nth-of-type(1)").appendTo(".questions"); }); $("#left").on("click", function () { $(".questions .question:nth-last-of-type(1)").prependTo(".questions"); }); // ------------- table ------------- tableTitle(); // ------------- FAQ ------------- autoHight(); $(window).resize(function () { autoHight(); tableTitle(); }); }); function tableTitle() { if (window.innerWidth > 768 && isTableMobile) { isTableMobile = false; $(window).off("scroll", scrollTableTitle); if ($(".title_table").css("display") != "none") $(".title_table").css("display", "none"); } else if (window.innerWidth <= 768 && !isTableMobile) { isTableMobile = true; $(window).on("scroll", scrollTableTitle); } } function scrollTableTitle() { if($(".table_comparison").length>0) { if ($(".table_comparison").offset().top + 100 <= $(window).scrollTop()) $(".title_table").addClass("active"); else $(".title_table").removeClass("active"); } } function autoHight() { var max = 0; $(".questions").height("auto"); $(".questions .question").height("auto"); $(".questions .question").each(function () { var elementHeight = $(this).height(); if (max < elementHeight) max = elementHeight; }); $(".questions .question").height(max + 60 + "px"); $(".questions").height(max + 140 + "px"); } $(".progress").each(function() { var value = $(this).attr('data-value'); var left = $(this).find('.progress-left .progress-bar'); var right = $(this).find('.progress-right .progress-bar'); if (value > 0) { if (value <= 50) { right.css('transform', 'rotate(' + percentageToDegrees(value) + 'deg)') } else { right.css('transform', 'rotate(180deg)') left.css('transform', 'rotate(' + percentageToDegrees(value - 50) + 'deg)') } } }) function percentageToDegrees(percentage) { return percentage / 100 * 360 } })(jQuery);