Permalink
Browse files

Bringing project up to date with live version at cablegatesearch.net

  • Loading branch information...
1 parent 6860340 commit 33ef6849be8ae527dfb27e709cf77608d7846e8a @gorhill committed Aug 31, 2011
Showing with 22 additions and 6 deletions.
  1. +22 −6 cablegate-cart.js
View
28 cablegate-cart.js
@@ -37,6 +37,18 @@ if (!CablegateObject) {
this.cartUpdatePermalink(key);
};
+ co.cartSynchronizeItems = function() {
+ $$('.cartToggler').each(function(e){
+ var id = co.cartItemIdFromElement(e);
+ if (co.cartContainsItem(id)) {
+ e.addClass('inCart');
+ }
+ else {
+ e.removeClass('inCart');
+ }
+ });
+ };
+
co.cartAddItem = function(id) {
var base64 = this.cartItemIdToBase64(id),
key;
@@ -61,7 +73,8 @@ if (!CablegateObject) {
co.cartRemoveAll = function() {
this.cart = {};
- this.saveCart();
+ this.cartSynchronizeItems();
+ this.cartSave();
this.cartUpdatePermalink();
};
@@ -136,16 +149,19 @@ if (!CablegateObject) {
window.addEvent('domready',function() {
co.cartUpdatePermalink();
$$('.cartToggler').each(function(e){
- var id = co.cartItemIdFromElement(e);
- if (co.cartContainsItem(id)) {
- e.addClass('inCart');
- }
e.addEvent('click', co.cartAddRemoveOnclickHandler);
});
+ co.cartSynchronizeItems();
// to auto-select whole field when clicked
- var e=$('cart-permalink');
+ var e = $('cart-permalink');
if (e){
e.addEvent('click',function(){this.focus();this.select();});
}
+ e = $('cart-remove-all');
+ if (e){
+ e.addEvent('click',function(){
+ if (confirm('Remove all cables from your private cart?')) {co.cartRemoveAll();}
+ });
+ }
});
}());

0 comments on commit 33ef684

Please sign in to comment.