Commit 7f57ad53135d393e7c6001eeba207e1e590be4c5
1 parent
9a9d88ed
уведомление о добавлении товара в корзину
Showing
2 changed files
with
22 additions
and
0 deletions
Show diff stats
frontend/web/css/style.css
| @@ -4639,4 +4639,18 @@ a.list-group-item.active > .badge, | @@ -4639,4 +4639,18 @@ a.list-group-item.active > .badge, | ||
| 4639 | -ms-transform: rotate(360deg); | 4639 | -ms-transform: rotate(360deg); |
| 4640 | transform: rotate(360deg); | 4640 | transform: rotate(360deg); |
| 4641 | } | 4641 | } |
| 4642 | +} | ||
| 4643 | + | ||
| 4644 | +.alert-cart{ | ||
| 4645 | + position: fixed; | ||
| 4646 | + z-index: 1001; | ||
| 4647 | + width: 50%; | ||
| 4648 | + left: 25%; | ||
| 4649 | + top: -75px; | ||
| 4650 | + box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.0); | ||
| 4651 | + transition: 0.3s; | ||
| 4652 | +} | ||
| 4653 | +.alert-cart.active{ | ||
| 4654 | + top: 30px; | ||
| 4655 | + box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.3); | ||
| 4642 | } | 4656 | } |
| 4643 | \ No newline at end of file | 4657 | \ No newline at end of file |
frontend/web/js/script.js
| @@ -111,7 +111,15 @@ $( | @@ -111,7 +111,15 @@ $( | ||
| 111 | e.preventDefault(); | 111 | e.preventDefault(); |
| 112 | var id = $(this) | 112 | var id = $(this) |
| 113 | .data('id'); | 113 | .data('id'); |
| 114 | + var alert_id = Math.floor(Math.random() * (999 - 100 + 1)) + 100; | ||
| 114 | basket.add(id, 1); | 115 | basket.add(id, 1); |
| 116 | + if ($('.alert-cart').length > 0) { | ||
| 117 | + } else { | ||
| 118 | + $('body').prepend($("<div class='alert-cart alert alert-success alert-dismissible' id='alert_"+alert_id+"'>Товар добавлен в корзину.</div>")); | ||
| 119 | + setTimeout(function(){$("#alert_"+alert_id).addClass("active");},100); | ||
| 120 | + setTimeout(function(){$("#alert_"+alert_id).removeClass("active");},3500); | ||
| 121 | + setTimeout(function(){$("#alert_"+alert_id).remove();},3600); | ||
| 122 | + } | ||
| 115 | }); | 123 | }); |
| 116 | 124 | ||
| 117 | $(document) | 125 | $(document) |