I am creating a website (with jQuery 1.4) that has a basket with a floating point (fixed position).
Current working functionality ( Demo here )
- When the user clicks on the basket, he switches the slides to open / close and switches the class to "locked"
- When the user clicks the "add element" link on the page that opens, adds the "on" class and disappears in the notification that the "element name" has been added
What I'm fighting
- If the user clicked the “add item” link: after 3 seconds the notification should disappear, the basket slide is closed and the “on” class will be deleted. BUT , this must be considered if the user desperately clicks 10 things quickly; updating the added text of the notification about the name of the track, not queuing up a bunch of attenuation / slides, but just staying open beautifully, and then sliding for 3 seconds from the moment the last element was added. And if the basket class is “locked” (that is, it has already been opened by the user), then only the notification should disappear, the basket should remain open.
javascript bye
$("#basket-button").click(function(){
$("#basket-contents").slideToggle();
$("#floating-basket").toggleClass("locked on");
return false
});
$(".buy-button").click(function(){
$("#basket-contents").slideDown();
$("#floating-basket").addClass("on");
$("#basket-trackname").text($(this).attr('name'));
$("#basket-message").fadeIn();
return false
});
HTML
<a class="buy-button" name="Item Name one" href="#">Buy</a>
<a class="buy-button" name="Item Name two" href="#">Buy</a>
<div id="floating-basket">
<div id="basket-message">
<strong id="basket-trackname"></strong> added to basket!
</div>
<a href="/basket" id="basket-button">My Basket <span id="basket-number">0</span></a>
<div id="basket-contents">
lorem
<a href="#">Checkout</a>
</div>
</div>
http://www.webresourcesdepot.com/ajaxed-sliding-shopping-cart-with-jquery - , - ( ).
:)