Blame view

web/js/script.js 3.26 KB
9568083b   Alexey Boroda   -Backend left
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
57
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
  $(document)
      .ready(function() {
          addClasses();
          forms();
          click();
  
          function addClasses() {
              $('.hidden-form input')
              $('.section-box-1')
                  .addClass('hidden-forms');
              $('.section-box-1')
                  .addClass('opacity-bg');
          }
  
          function click() {
              $('body')
                  .on('click', '.first-btn', function() {
                      $('.section-box-1')
                          .addClass('start');
                  })
          }
  
          function forms() {
              $('.hidden-form input')
                  .focus(function() {
                      $(this)
                          .parent()
                          .addClass('hidden-label')
  
                  });
              $('.hidden-form input')
                  .focusout(function() {
                      if ($(this)
                              .val() == '') {
                          $(this)
                              .parent()
                              .removeClass('hidden-label')
                      }
  
                  })
  
              $('.hidden-form form')
                  .submit(function() {
                      var name = $('#input-name')
                          .val();
                      var $emailInput = $('#input-email');
                      var email = $emailInput.val();
                      var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
                      if (!re.test(String(email)
                              .toLowerCase())) {
                          $emailInput.parent()
                                     .addClass('has-error');
                          return false;
                      } else {
                          $emailInput.parent()
                                     .removeClass('has-error');
                      }
  
                      $.ajax({
                          url: '/subscribe',
                          type: 'POST',
                          data: {
                              name: name,
                              email: email
                          },
                          success: function() {
                              showMap();
                          },
                          error: function() {
                              showMap();
                          }
                      });
                      return false;
                  })
  
              $('body')
                  .on('click', '.second-btn', function() {
                      showMap();
                  })
  
              function showMap() {
                  $('.section-box-1')
                      .removeClass('opacity-remove')
                      .addClass('timing');
                  setTimeout(function() {
                      $('.section-box-1')
                          .addClass('opacity-block')
                  }, 800);
                  setTimeout(function() {
                      $('[class*="section-box-"]')
                          .removeClass('active');
                      $('.section-box-map')
                          .addClass('active');
                  }, 800 + 1000);
              }
  
          }
  
          window.onload = function() {
              $('.section-box-1')
                  .addClass('opacity-remove');
          }
  
      })