$( function() { modalForms(); closeForms(); function modalForms() { $('body').on('click','.modal-link', function (e) { e.preventDefault(); var idForm = $(this).data('form'); // console.log(idForm); var pos = ($(window).scrollTop()+30+50); // console.log(pos); $('#overlay').fadeIn(400, function(){ $('#'+idForm) .css('display', 'block') .animate({opacity: 1, top: pos}, 200); }); $("body").addClass("off-scroll"); }) } function closeForms() { $('.close, #overlay').click( function(){ $('.forms_').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $('#overlay').fadeOut(400); }); $('.success_').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $('#overlay').fadeOut(400); }); $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $(this).css({top:'50%'}); }); $("body").removeClass("off-scroll"); }); } $(".on_input_").on('click', function(){ $(this).addClass("actived"); $(this).parent().find("input").focus(); }); $(".modal_form input").on('focusout', function(){ $(".on_input_.actived").removeClass("actived"); }); $(".bnm.btn").on('click', function(){ $("#booknow-modal .modal-title").html($(this).data('title')); $("#booknow-modal #booknow-tour").val($(this).data('title')); }); $(".success_ button").click(function(){ $(".success_").removeClass("done_"); }); $("#success-modal button.btn.btn-template-primary").click(function(){ $(".close").click(); $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $(this).css({top:'50%'}); }); $('#success-modal').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $(this).css({top:'50%'}); }); }); $(".overlay-new").click(function(){ $(".close").click(); }); } );