Bugzilla – Attachment 131838 Details for
Bug 29940
Phase out jquery.cookie.js in the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29940: Phase out jquery.cookie.js in the OPAC
Bug-29940-Phase-out-jquerycookiejs-in-the-OPAC.patch (text/plain), 9.77 KB, created by
Marcel de Rooy
on 2022-03-17 12:53:07 UTC
(
hide
)
Description:
Bug 29940: Phase out jquery.cookie.js in the OPAC
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-03-17 12:53:07 UTC
Size:
9.77 KB
patch
obsolete
>From 2aeb1751cc8b4d2eb99bfa117c9b3f2a65f85270 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 25 Jan 2022 12:32:28 +0000 >Subject: [PATCH] Bug 29940: Phase out jquery.cookie.js in the OPAC >Content-Type: text/plain; charset=utf-8 > >This patch replaces the use of jquery.cookie.js in the OPAC with the >newer js-cookie plugin. The patch adds the latest version of the >js-cookie library and removes the old jquery.cookie plugin. > >To test, apply the patch and go to the advanced search page in the OPAC. > >- Perform a search using a number of different limits and settings, e.g. > keyword, item type, and sort-by. >- On the search results page you should see at the top of the results > list a link to "Return to the last advanced search." >- The link should take you back to the advanced search page with all the > same settings filled into the form. >- A search with the "More options" view enabled in the advanced search > form should result in a link which returns to the "More options" view. >- Searching via the "quick search" form at the top of the page should > clear the cookies which were set in order to remember the advanced > search. See > https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector for > information on viewing your browser's stored cookies. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > .../bootstrap/en/includes/opac-bottom.inc | 8 ++++---- > .../bootstrap/en/modules/opac-advsearch.tt | 20 +++++++++---------- > .../lib/jquery/plugins/jquery.cookie.min.js | 2 -- > .../lib/js-cookie/js.cookie-3.0.1.min.js | 2 ++ > 4 files changed, 15 insertions(+), 17 deletions(-) > delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.cookie.min.js > create mode 100644 koha-tmpl/opac-tmpl/lib/js-cookie/js.cookie-3.0.1.min.js > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index fb57e6c18d..37340e20c1 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -280,14 +280,14 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > </script> > [% END %] > >-[% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") | $raw %] >+[% Asset.js("lib/js-cookie/js.cookie-3.0.1.min.js") | $raw %] > <script> > $(document).ready(function() { > if($('#searchsubmit').length) { > $(document).on("click", '#searchsubmit', function(e) { >- jQuery.removeCookie("form_serialized", { path: '/'}); >- jQuery.removeCookie("form_serialized_limits", { path: '/'}); >- jQuery.removeCookie("search_path_code", { path: '/'}); >+ Cookies.remove("form_serialized", { path: '/'}); >+ Cookies.remove("form_serialized_limits", { path: '/'}); >+ Cookies.remove("search_path_code", { path: '/'}); > }); > } > }); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >index baf8aec28b..3135afd03b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >@@ -449,7 +449,6 @@ > > [% BLOCK jsinclude %] > [% Asset.js("lib/jquery/plugins/jquery.deserialize.min.js") | $raw %] >-[% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") | $raw %] > <script> > $(document).ready(function() { > [% IF search_groups %] >@@ -472,12 +471,11 @@ $(document).ready(function() { > [% END %] > > $('#advsearches').tabs(); >- jQuery.cookie.json = true; > > $('.search-term-row .search-term-input select[name="op"]').first().prop("disabled",true).hide(); > > [% IF ( ReturnToSearch ) %] >- if (form_serialized = jQuery.cookie("form_serialized")) { >+ if (form_serialized = JSON.parse( Cookies.get("form_serialized") ) ) { > // Add missing term inputs if there were more than 3 > var count = (form_serialized.match(/&q=/g) || []).length; > for(var i = 3 ; i < count ; i++) { >@@ -485,7 +483,7 @@ $(document).ready(function() { > } > $('#advsearch form').deserialize(form_serialized); > } >- if (form_serialized_limits = jQuery.cookie("form_serialized_limits")) { >+ if (form_serialized_limits = JSON.parse( Cookies.get("form_serialized_limits") ) ) { > $('#language-limit') .val(form_serialized_limits[0]); > $('#branchloop') .val(form_serialized_limits[1]); > $('#subtype_audience') .val(form_serialized_limits[2]); >@@ -496,9 +494,9 @@ $(document).ready(function() { > } > [% ELSE %] > //Clear all form cookies >- jQuery.removeCookie("form_serialized", { path: '/'}); >- jQuery.removeCookie("form_serialized_limits", { path: '/'}); >- jQuery.removeCookie("search_path_code", { path: '/'}); >+ Cookies.remove("form_serialized", { path: '/'}); >+ Cookies.remove("form_serialized_limits", { path: '/'}); >+ Cookies.remove("search_path_code", { path: '/'}); > [% END %] > $('#advsearch form').submit(function() { > $('[name^="limit"]').each(function(){ >@@ -514,18 +512,18 @@ $(document).ready(function() { > } > }); > form_serialized = $(this).serialize(); >- jQuery.cookie("form_serialized", form_serialized,{ path: '/'}); >+ Cookies.set("form_serialized", JSON.stringify( form_serialized ), { path: '/'}); > form_serialized_limits = [ > $('#language-limit').val(), $('#branchloop').val(), > $('#subtype_audience').val(), $('#subtype_content').val(), > $('#subtype_format').val(), $('#subtype_additional').val(), > $('#locloop').val() > ]; >- jQuery.cookie("form_serialized_limits", form_serialized_limits,{ path: '/'}); >+ Cookies.set("form_serialized_limits", JSON.stringify( form_serialized_limits ),{ path: '/'}); > [% IF ( expanded_options ) %] >- jQuery.cookie("search_path_code", 'exs',{ path: '/'}); >+ Cookies.set("search_path_code", JSON.stringify('exs'), { path: '/'}); > [% ELSE %] >- jQuery.cookie("search_path_code", 'ads',{ path: '/'}); >+ Cookies.set("search_path_code", JSON.stringify('ads'), { path: '/'}); > [% END %] > }); > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.cookie.min.js b/koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.cookie.min.js >deleted file mode 100644 >index 36d6b65eed..0000000000 >--- a/koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.cookie.min.js >+++ /dev/null >@@ -1,2 +0,0 @@ >-/*! jquery.cookie v1.4.1 | MIT */ >-!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}}); >diff --git a/koha-tmpl/opac-tmpl/lib/js-cookie/js.cookie-3.0.1.min.js b/koha-tmpl/opac-tmpl/lib/js-cookie/js.cookie-3.0.1.min.js >new file mode 100644 >index 0000000000..90a7672232 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/lib/js-cookie/js.cookie-3.0.1.min.js >@@ -0,0 +1,2 @@ >+/*! js-cookie v3.0.1 | MIT */ >+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,(function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}return function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})})); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29940
:
129749
|
129835
|
129890
|
129891
| 131838 |
131839