From f9282eca291e44da795cc62bc8ff5593107c5cb5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 18 Jun 2016 16:39:45 +0100 Subject: [PATCH] Bug 16490: Tidy updateLink and updateAllLinks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Went through test plan, works as expected. Signed-off-by: Marc Véron Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- koha-tmpl/intranet-tmpl/prog/js/basket.js | 25 ++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/basket.js b/koha-tmpl/intranet-tmpl/prog/js/basket.js index f2d1d6484f..1329f7b7b5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/basket.js +++ b/koha-tmpl/intranet-tmpl/prog/js/basket.js @@ -454,23 +454,16 @@ function hideCart(){ $("#cartDetails").fadeOut("fast"); } -function updateLink(val,op,target){ - if(target){ - if(op == "add"){ - target.$("#cart"+val).html(MSG_ITEM_IN_CART).addClass("incart"); - target.$("#cartR"+val).show(); - } else { - target.$("#cart"+val).html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart"); - target.$("#cartR"+val).hide(); - } +function updateLink(val, op, target){ + var cart = target ? target.$("#cart" + val) : $("#cart" + val); + var cartR = target ? target.$("#cartR" + val) : $("#cartR" + val); + + if(op == "add"){ + cart.html(MSG_ITEM_IN_CART).addClass("incart"); + cartR.show(); } else { - if(op == "add"){ - $("#cart"+val).html(MSG_ITEM_IN_CART).addClass("incart"); - $("#cartR"+val).show(); - } else { - $("#cart"+val).html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart"); - $("#cartR"+val).hide(); - } + cart.html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart"); + cartR.hide(); } } -- 2.39.5