modal.js 3.48 KB
$(
  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;
              $('#overlay').fadeIn(400,
                  function(){
                      $('#'+idForm)
                          .css('display', 'block')
                          .animate({opacity: 1}, 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_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();
      });
      $(".forms_ input").on('focusout', function(){
          $(".on_input_.actived").removeClass("actived");
      });

      //      $(document)
      //          .on(
      //              'beforeSubmit', '.forms_ form', function() {
      //                  var f = this;
      //                  var form = $(this);
      //                  var formData = form.serialize();
      //                  console.log(formData);
      //                  $.ajax(
      //                      {
      //                          url: form.attr("action"),
      //                          type: form.attr("method"),
      //                          data: formData,
      //                          success: function(data) {
      //                              f.reset();
      //                              // form.replaceWith(data.alert)
      //                              // $(".modal-dialog").append(data.alert);
      //                              // setTimeout(function(){location.reload()}, 5000);
      //                              $(".close").click();
      //                              $(".success_").animate({opacity: 1, top: '40'}, 200).addClass("done_");
      //                              setTimeout(function(){$(".success_").animate({opacity: 0, top: '0'}, 200,function(){
      //                                  $(this).removeClass("done_");
      //                              })}, 4000);
      //
      //                          },
      //                          error: function() {
      //
      //                          }
      //                      }
      //                  );
      //              }
      //          )
      //          .on(
      //              'submit', '.forms_ form', function(e) {
      //                  e.preventDefault();
      //              }
      //          );


      $(".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_");
      });
      $(".overlay-new").click(function(){
          $(".close").click();
      });
  }
);