$(document).ready(function(){ function addRemoveBlocks(){ $('#overlay, .forms-modal-hide').remove(); $('body').append('
').append(''); } function addToLogin(){ $.post("/site/forms-modal-login", function (data) { $('.forms-modal-hide').append(data) }) .fail(function(){ $('#overlay, .forms-modal-hide').remove(); alert(txtErrorModal) }) .done(function() { var newMarg = $(window).scrollTop(); $('#overlay').fadeIn(400, function(){ $('.forms-modal-hide>div') .css({display:'block', marginTop:-230+newMarg}) .animate({opacity: 1, top: '50%'}, 200); }); }) } function addToFavorites(){ $.post("/site/forms-modal-fav", function (data) { $('.forms-modal-hide').append(data) }) .fail(function(){ $('#overlay, .forms-modal-hide').remove(); alert(txtErrorModal) }) .done(function() { var newMarg = $(window).scrollTop(); $('#overlay').fadeIn(400, function(){ $('.forms-modal-hide>div') .css({display:'block', marginTop:-230+newMarg}) .animate({opacity: 1, top: '50%'}, 200); }); }) } function addToOffer(){ $.post("/site/forms-modal-offer", function (data) { $('.forms-modal-hide').append(data) }) .fail(function(){ $('#overlay, .forms-modal-hide').remove(); alert(txtErrorModal) }) .done(function() { var newMarg = $(window).scrollTop(); $('#overlay').fadeIn(400, function(){ $('body').css({overflowY:'hidden'}) $('.forms-modal-hide>div') .css({display:'block', marginTop:-230+newMarg}) .animate({opacity: 1, top: '50%'}, 200); }); }) } function addContacts() { $.post("/site/forms-modal-contacts", function (data) { $('.forms-modal-hide').append(data) }) .fail(function(){ $('#overlay, .forms-modal-hide').remove(); alert(txtErrorModal) }) .done(function() { var newMarg = $(window).scrollTop(); $('#overlay').fadeIn(400, function(){ $('.forms-modal-hide>div') .css({display:'block', marginTop:-230+newMarg}) .animate({opacity: 1, top: '50%'}, 200); }); }) } //login $('a.loginLinkModal').click(function(e){ e.preventDefault() addRemoveBlocks() addToLogin() }) //contacts $('a.contactsLinkModalFirst').click(function(e){ e.preventDefault() addRemoveBlocks() addContacts() }) //bookmarks $('.get-list, .performance-vacancy-add-favorite a, .blog-buttons-add-favorite').click(function(e){ e.preventDefault() addRemoveBlocks() addToFavorites() }) //offer $('a.get-project, .blog-buttons-offer').click(function(e){ e.preventDefault() addRemoveBlocks() addToOffer() }) var txtErrorModal = 'ВОЗНИКЛА ОШИБКА, ПОПРОБУЙТЕ ЕЩЕ РАЗ ПОЗЖЕ!'; clocseModalForms() function clocseModalForms(){ $('body').on('click','.closed-form, #overlay', function(){ $('body').css({overflowY:'visible'}) $('.forms-modal-hide>div') .animate({opacity: 0, top: '30%'}, 200, function(){ $(this).css('display', 'none') $('#overlay').fadeOut(400,function(){$('#overlay, .forms-modal-hide').remove()}) } ) }); } })