Blame view

frontend/web/js/forms.js 4.07 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
  
f61f63e2   Виталий   tokar commit
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
      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);
                      });
              })
      }
  
bca37b08   Виталий   tokar commit
26
      function addToFavorites(){
6d34dbf1   Виталий   tokar commit
27
28
          $.post("/site/forms-modal-fav", 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
45
      }
  
      function addToOffer(){
6d34dbf1   Виталий   tokar commit
46
47
          $.post("/site/forms-modal-offer", function (data) {
              $('.forms-modal-hide').append(data)
bca37b08   Виталий   tokar commit
48
          })
6d34dbf1   Виталий   tokar commit
49
50
51
52
53
54
55
56
57
58
59
60
61
              .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
62
63
      }
  
b70239a0   Виталий   tokar commit
64
65
      function addContacts() {
          $.post("/site/forms-modal-contacts", function (data) {
71e78660   Виталий   tokar commit
66
67
68
                  $('.forms-modal-hide').append(data)
          })
              .fail(function(){
6d34dbf1   Виталий   tokar commit
69
70
                  $('#overlay, .forms-modal-hide').remove();
              alert(txtErrorModal)
71e78660   Виталий   tokar commit
71
72
73
74
75
76
77
78
79
80
81
82
          })
              .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);
                      });
          })
      }
  
f61f63e2   Виталий   tokar commit
83
84
85
86
87
88
      //login
      $('a.loginLinkModal').click(function(e){
          e.preventDefault()
          addRemoveBlocks()
          addToLogin()
      })
6d34dbf1   Виталий   tokar commit
89
      //contacts
b70239a0   Виталий   tokar commit
90
      $('a.contactsLinkModalFirst').click(function(e){
bca37b08   Виталий   tokar commit
91
92
          e.preventDefault()
          addRemoveBlocks()
6d34dbf1   Виталий   tokar commit
93
94
95
96
97
98
99
100
101
102
103
104
105
          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
106
107
      })
  
6d34dbf1   Виталий   tokar commit
108
109
      var txtErrorModal = 'ВОЗНИКЛА ОШИБКА, ПОПРОБУЙТЕ ЕЩЕ РАЗ ПОЗЖЕ!';
  
71e78660   Виталий   tokar commit
110
111
112
113
114
115
116
117
118
119
      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
120
  
71e78660   Виталий   tokar commit
121
122
          });
      }
bca37b08   Виталий   tokar commit
123
  
bca37b08   Виталий   tokar commit
124
  })