Blame view

frontend/web/js/forms.js 3.27 KB
7fc05ac5   Yarik   test
1
  $(document).ready(function(){
bca37b08   Виталий   tokar commit
2
3
4
5
      function addRemoveBlocks(){
          $('#overlay, .forms-modal-hide').remove();
          $('body').append('<div id="overlay"></div>').append('<div class="forms-modal-hide"></div>');
      }
bca37b08   Виталий   tokar commit
6
7
  
      function addToFavorites(){
6d34dbf1   Виталий   tokar commit
8
9
          $.post("/site/forms-modal-fav", function (data) {
              $('.forms-modal-hide').append(data)
bca37b08   Виталий   tokar commit
10
          })
6d34dbf1   Виталий   tokar commit
11
12
13
14
15
16
17
18
19
20
21
22
23
              .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);
                      });
              })
bca37b08   Виталий   tokar commit
24
25
26
      }
  
      function addToOffer(){
6d34dbf1   Виталий   tokar commit
27
28
          $.post("/site/forms-modal-offer", function (data) {
              $('.forms-modal-hide').append(data)
bca37b08   Виталий   tokar commit
29
          })
6d34dbf1   Виталий   tokar commit
30
31
32
33
34
35
36
37
38
39
40
41
42
              .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);
                      });
              })
bca37b08   Виталий   tokar commit
43
44
      }
  
b70239a0   Виталий   tokar commit
45
46
      function addContacts() {
          $.post("/site/forms-modal-contacts", function (data) {
71e78660   Виталий   tokar commit
47
48
49
                  $('.forms-modal-hide').append(data)
          })
              .fail(function(){
6d34dbf1   Виталий   tokar commit
50
51
                  $('#overlay, .forms-modal-hide').remove();
              alert(txtErrorModal)
71e78660   Виталий   tokar commit
52
53
54
55
56
57
58
59
60
61
62
63
          })
              .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);
                      });
          })
      }
  
6d34dbf1   Виталий   tokar commit
64
      //contacts
b70239a0   Виталий   tokar commit
65
      $('a.contactsLinkModalFirst').click(function(e){
bca37b08   Виталий   tokar commit
66
67
          e.preventDefault()
          addRemoveBlocks()
6d34dbf1   Виталий   tokar commit
68
69
70
71
72
73
74
75
76
77
78
79
80
          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()
bca37b08   Виталий   tokar commit
81
82
      })
  
6d34dbf1   Виталий   tokar commit
83
84
      var txtErrorModal = 'ВОЗНИКЛА ОШИБКА, ПОПРОБУЙТЕ ЕЩЕ РАЗ ПОЗЖЕ!';
  
71e78660   Виталий   tokar commit
85
86
87
88
89
90
91
92
93
94
      clocseModalForms()
      function clocseModalForms(){
          $('body').on('click','.closed-form, #overlay', function(){
              $('.forms-modal-hide>div')
                  .animate({opacity: 0, top: '30%'}, 200,
                  function(){
                      $(this).css('display', 'none')
                      $('#overlay').fadeOut(400,function(){$('#overlay, .forms-modal-hide').remove()})
                  }
              )
bca37b08   Виталий   tokar commit
95
  
71e78660   Виталий   tokar commit
96
97
          });
      }
bca37b08   Виталий   tokar commit
98
  
bca37b08   Виталий   tokar commit
99
  })