Blame view

frontend/web/js/forms.js 4.3 KB
eb7e82fb   Administrator   29.02.16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  $(document).ready(function(){

      function addRemoveBlocks(){

          $('#overlay, .forms-modal-hide').remove();

          $('body').append('<div id="overlay"></div>').append('<div class="forms-modal-hide"></div>');

      }

  

      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(){

01cd3c0f   Виталий   tokar commit
57
                          $('body').css({overflowY:'hidden'})

eb7e82fb   Administrator   29.02.16
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
                          $('.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(){

01cd3c0f   Виталий   tokar commit
114
              $('body').css({overflowY:'visible'})

eb7e82fb   Administrator   29.02.16
115
116
117
118
119
120
121
122
123
124
125
              $('.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
126
  })