From 7f57ad53135d393e7c6001eeba207e1e590be4c5 Mon Sep 17 00:00:00 2001 From: Eugeny Galkovskiy Date: Wed, 10 May 2017 13:10:22 +0300 Subject: [PATCH] уведомление о добавлении товара в корзину --- frontend/web/css/style.css | 14 ++++++++++++++ frontend/web/js/script.js | 8 ++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/frontend/web/css/style.css b/frontend/web/css/style.css index 15053ed..f4c1cbd 100755 --- a/frontend/web/css/style.css +++ b/frontend/web/css/style.css @@ -4639,4 +4639,18 @@ a.list-group-item.active > .badge, -ms-transform: rotate(360deg); transform: rotate(360deg); } +} + +.alert-cart{ + position: fixed; + z-index: 1001; + width: 50%; + left: 25%; + top: -75px; + box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.0); + transition: 0.3s; +} +.alert-cart.active{ + top: 30px; + box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.3); } \ No newline at end of file diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js index 01842c6..884d85a 100755 --- a/frontend/web/js/script.js +++ b/frontend/web/js/script.js @@ -111,7 +111,15 @@ $( e.preventDefault(); var id = $(this) .data('id'); + var alert_id = Math.floor(Math.random() * (999 - 100 + 1)) + 100; basket.add(id, 1); + if ($('.alert-cart').length > 0) { + } else { + $('body').prepend($("
Товар добавлен в корзину.
")); + setTimeout(function(){$("#alert_"+alert_id).addClass("active");},100); + setTimeout(function(){$("#alert_"+alert_id).removeClass("active");},3500); + setTimeout(function(){$("#alert_"+alert_id).remove();},3600); + } }); $(document) -- libgit2 0.21.4