From 337b46fa4088335b8da5263cb7f84b127a807bd8 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Tue, 10 Dec 2013 19:12:01 +0200 Subject: [PATCH] Bug 11369 - Updating the jquery.cookie.js-plugin The current jquery.cookie-plugin crashes when trying to fetch all cookies using $.cookie(); Downloaded the newest plugin version and minified it. Now works as intended. Encountered an issue with the plugin now returning null when no cookies are found, and applied a fix in browser.js. ------------- - Test plan - ------------- Plugin is used in browser.js and batchMod.js so testing both --- browser.js --- In catalogue/search.pl look for any record. You should get a search cookie stored in your browsers cache with the following format: 4Xea40qp : {"offset":1,"query":"idx=kw&q=read","limit":"","sort":"","pagelen":20,"results":[1430,2253,2255,2256,2257,2258,2307,2326,2344,2595,2961,3588,3974,3995,4026,4405,4410,4412,4414,4435]} Select any record for detailed view. You should get a navigation panel on your left part of screen. You should be able to move to the previous and next record and return to results. --- batchMod.js --- Select a handful of barcodes to batch modify, then continue. The cookie affected stores the columns you want displayed. Try showing/hiding columns. When you make another batch modification attempt, your column selection persists via the showColumns-cookie. --- koha-tmpl/intranet-tmpl/js/browser.js | 5 ++++- koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.cookie.min.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/js/browser.js b/koha-tmpl/intranet-tmpl/js/browser.js index fd99bb1..c3c1516 100644 --- a/koha-tmpl/intranet-tmpl/js/browser.js +++ b/koha-tmpl/intranet-tmpl/js/browser.js @@ -5,7 +5,10 @@ KOHA.browser = function (searchid, biblionumber) { this.searchid = searchid; if (me.searchid) { - me.searchCookie = JSON.parse($.cookie(searchid)); + var cookie = $.cookie(searchid) + if (cookie) { + me.searchCookie = JSON.parse(cookie); + } } var browseRecords = function (searchid, movement) { diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.cookie.min.js b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.cookie.min.js index eb129db..2ec98c0 100644 --- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.cookie.min.js +++ b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.cookie.min.js @@ -1 +1 @@ -jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h