Blame view

js/new-basket.js 2.48 KB
f4ab266e   Виталий   qwerty
1
  $(document).ready(function() {
2cb6cca4   Виталий   qwerty
2
      alert('alert')
f4ab266e   Виталий   qwerty
3
4
5
6
7
      modalForms();
      closeForms();
      function modalForms() {
          $('body').on('click', '.modal-link', function (e) {
              e.preventDefault();
f4ab266e   Виталий   qwerty
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
              var idForm = $(this).data('form');
              var pos = ($(window).scrollTop()) + 30;
  
              if($(this).hasClass('pos-top')){
                  pos = 30;
              }
  
              $('#overlay').fadeIn(400,
                  function(){
                      $('#'+idForm).css('display', 'block').animate({opacity: 1, top: pos}, 200);
                  }
              );
          })
      }
  
  
      function closeForms() {
          $('#modal_close, #overlay, .close-basket, .basket-close').click( function(){
              $('.forms_, .new-basket-modal').animate({opacity: 0, top: '0'}, 200,function(){
                  $(this).css('display', 'none');
                  $(this).prev("#overlay").css('display', 'none');
                  $('#overlay').fadeOut(400);
              });
              $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){
                  $(this).css('display', 'none');
                  $(this).prev("#overlay").css('display', 'none');
                  $(this).css({top:'50%'});
              });
          });
      }
  
5e4ecece   Виталий   qwerty
39
40
41
42
43
      $(document).on('click', '.new-btn-modal-basket', showBasket);
      $(document).on('click', '.basket-card', showBasket);
  
      function showBasket(e) {
          e.preventDefault();
2cb6cca4   Виталий   qwerty
44
          alert('qwerty')
5e4ecece   Виталий   qwerty
45
46
47
48
49
50
51
52
53
54
55
56
  
          var idForm = 'new-basket-modal';
          var pos = ($(window).scrollTop()) + 30;
  
          $('#overlay').fadeIn(400,
              function(){
                  $('#'+idForm).css('display', 'block').animate({opacity: 1, top: pos}, 200);
              }
          );
      }
  
  
f4ab266e   Виталий   qwerty
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
      $(document).on('click', '.quantity-wr span', changeBasket);
      $(document).on('keypress', '.quantity-wr input', setControl);
  
      function changeBasket(e) {
          e.preventDefault();
  
          var input = $(this).parent().parent().find('input');
          var oldVal = input.val();
          console.log(oldVal)
          if ($(this).hasClass('minus')) {
  
              if (oldVal > 1) {
                  oldVal--;
                  input.val(oldVal);
              }
          } else {
              oldVal++;
              input.val(oldVal);
  
          }
      }
      function setControl(e) {
          if (e.which == 13) {
              $(this)
                  .trigger('change');
              return false;
          } else if (!(e.which == 8 || (e.which > 47 && e.which < 58))) {
              return false;
          }
      }
  })