From 1b43d64a7113fe3acbe87926e7e5ceb04672c624 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 24 Mar 2008 15:20:03 -0500 Subject: [PATCH] Adding function to empty cart when user logs out. Signed-off-by: Joshua Ferraro --- koha-tmpl/opac-tmpl/prog/en/js/basket.js | 4 ++++ koha-tmpl/opac-tmpl/prog/en/js/script.js | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/prog/en/js/basket.js b/koha-tmpl/opac-tmpl/prog/en/js/basket.js index bec731958d..56ea21b3cc 100644 --- a/koha-tmpl/opac-tmpl/prog/en/js/basket.js +++ b/koha-tmpl/opac-tmpl/prog/en/js/basket.js @@ -58,7 +58,11 @@ function readCookie(name, wd) { function delCookie(name) { var exp = new Date(); exp.setTime(exp.getTime()-1); + if(parent.opener){ parent.opener.document.cookie = name + "=null; expires=" + exp.toGMTString(); + } else { + document.cookie = name + "=null; expires=" + exp.toGMTString(); + } } /////////////////////////////////////////////////////////////////// diff --git a/koha-tmpl/opac-tmpl/prog/en/js/script.js b/koha-tmpl/opac-tmpl/prog/en/js/script.js index 3241659659..09d9287921 100644 --- a/koha-tmpl/opac-tmpl/prog/en/js/script.js +++ b/koha-tmpl/opac-tmpl/prog/en/js/script.js @@ -10,6 +10,18 @@ $(document).ready(function(){ $(".close").click(function(){ window.close(); }); + // clear the basket when user logs out + $("#logout").click(function(){ + var nameCookie = "bib_list"; + var valCookie = readCookie(nameCookie); + if (valCookie) { // basket has contents + updateBasket(0,null); + delCookie(nameCookie); + return true; + } else { + return true; + } + }); }); // build Change Language menus @@ -51,4 +63,3 @@ YAHOO.util.Event.onContentReady("listsmenu", function () { YAHOO.util.Event.addListener("listsmenulink", "click", listMenu.show, null, listMenu); YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionlistMenu); }); - -- 2.39.5