View | Details | Raw Unified | Return to bug 29940
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-4 / +4 lines)
Lines 295-308 $.widget.bridge('uitooltip', $.ui.tooltip); Link Here
295
</script>
295
</script>
296
[% END %]
296
[% END %]
297
297
298
[% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") | $raw %]
298
[% Asset.js("lib/js-cookie/js.cookie-3.0.1.min.js") | $raw %]
299
<script>
299
<script>
300
$(document).ready(function() {
300
$(document).ready(function() {
301
    if($('#searchsubmit').length) {
301
    if($('#searchsubmit').length) {
302
        $(document).on("click", '#searchsubmit', function(e) {
302
        $(document).on("click", '#searchsubmit', function(e) {
303
            jQuery.removeCookie("form_serialized", { path: '/'});
303
            Cookies.remove("form_serialized", { path: '/'});
304
            jQuery.removeCookie("form_serialized_limits", { path: '/'});
304
            Cookies.remove("form_serialized_limits", { path: '/'});
305
            jQuery.removeCookie("search_path_code", { path: '/'});
305
            Cookies.remove("search_path_code", { path: '/'});
306
        });
306
        });
307
    }
307
    }
308
});
308
});
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt (-11 / +9 lines)
Lines 449-455 Link Here
449
449
450
[% BLOCK jsinclude %]
450
[% BLOCK jsinclude %]
451
[% Asset.js("lib/jquery/plugins/jquery.deserialize.min.js") | $raw %]
451
[% Asset.js("lib/jquery/plugins/jquery.deserialize.min.js") | $raw %]
452
[% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") | $raw %]
453
<script>
452
<script>
454
$(document).ready(function() {
453
$(document).ready(function() {
455
    [% IF search_groups %]
454
    [% IF search_groups %]
Lines 472-483 $(document).ready(function() { Link Here
472
    [% END %]
471
    [% END %]
473
472
474
    $('#advsearches').tabs();
473
    $('#advsearches').tabs();
475
    jQuery.cookie.json = true;
476
474
477
    $('.search-term-row .search-term-input select[name="op"]').first().prop("disabled",true).hide();
475
    $('.search-term-row .search-term-input select[name="op"]').first().prop("disabled",true).hide();
478
476
479
    [% IF ( ReturnToSearch ) %]
477
    [% IF ( ReturnToSearch ) %]
480
        if (form_serialized = jQuery.cookie("form_serialized")) {
478
        if (form_serialized = JSON.parse( Cookies.get("form_serialized") ) ) {
481
            // Add missing term inputs if there were more than 3
479
            // Add missing term inputs if there were more than 3
482
            var count = (form_serialized.match(/&q=/g) || []).length;
480
            var count = (form_serialized.match(/&q=/g) || []).length;
483
            for(var i = 3 ; i < count ; i++) {
481
            for(var i = 3 ; i < count ; i++) {
Lines 485-491 $(document).ready(function() { Link Here
485
            }
483
            }
486
            $('#advsearch form').deserialize(form_serialized);
484
            $('#advsearch form').deserialize(form_serialized);
487
        }
485
        }
488
        if (form_serialized_limits = jQuery.cookie("form_serialized_limits")) {
486
        if (form_serialized_limits = JSON.parse( Cookies.get("form_serialized_limits") ) ) {
489
            $('#language-limit')     .val(form_serialized_limits[0]);
487
            $('#language-limit')     .val(form_serialized_limits[0]);
490
            $('#branchloop')         .val(form_serialized_limits[1]);
488
            $('#branchloop')         .val(form_serialized_limits[1]);
491
            $('#subtype_audience')   .val(form_serialized_limits[2]);
489
            $('#subtype_audience')   .val(form_serialized_limits[2]);
Lines 496-504 $(document).ready(function() { Link Here
496
        }
494
        }
497
    [% ELSE %]
495
    [% ELSE %]
498
        //Clear all form cookies
496
        //Clear all form cookies
499
        jQuery.removeCookie("form_serialized", { path: '/'});
497
        Cookies.remove("form_serialized", { path: '/'});
500
        jQuery.removeCookie("form_serialized_limits", { path: '/'});
498
        Cookies.remove("form_serialized_limits", { path: '/'});
501
        jQuery.removeCookie("search_path_code", { path: '/'});
499
        Cookies.remove("search_path_code", { path: '/'});
502
    [% END %]
500
    [% END %]
503
    $('#advsearch form').submit(function() {
501
    $('#advsearch form').submit(function() {
504
        $('[name^="limit"]').each(function(){
502
        $('[name^="limit"]').each(function(){
Lines 514-531 $(document).ready(function() { Link Here
514
            }
512
            }
515
        });
513
        });
516
        form_serialized = $(this).serialize();
514
        form_serialized = $(this).serialize();
517
        jQuery.cookie("form_serialized", form_serialized,{ path: '/'});
515
        Cookies.set("form_serialized", JSON.stringify( form_serialized ), { path: '/'});
518
        form_serialized_limits = [
516
        form_serialized_limits = [
519
            $('#language-limit').val(),   $('#branchloop').val(),
517
            $('#language-limit').val(),   $('#branchloop').val(),
520
            $('#subtype_audience').val(), $('#subtype_content').val(),
518
            $('#subtype_audience').val(), $('#subtype_content').val(),
521
            $('#subtype_format').val(),   $('#subtype_additional').val(),
519
            $('#subtype_format').val(),   $('#subtype_additional').val(),
522
            $('#locloop').val()
520
            $('#locloop').val()
523
        ];
521
        ];
524
        jQuery.cookie("form_serialized_limits", form_serialized_limits,{ path: '/'});
522
        Cookies.set("form_serialized_limits", JSON.stringify( form_serialized_limits ),{ path: '/'});
525
        [% IF ( expanded_options ) %]
523
        [% IF ( expanded_options ) %]
526
        jQuery.cookie("search_path_code", 'exs',{ path: '/'});
524
            Cookies.set("search_path_code", JSON.stringify('exs'), { path: '/'});
527
        [% ELSE %]
525
        [% ELSE %]
528
        jQuery.cookie("search_path_code", 'ads',{ path: '/'});
526
            Cookies.set("search_path_code", JSON.stringify('ads'), { path: '/'});
529
        [% END %]
527
        [% END %]
530
    });
528
    });
531
529
(-)a/koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.cookie.min.js (-2 lines)
Lines 1-2 Link Here
1
/*! jquery.cookie v1.4.1 | MIT */
2
!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))}});
(-)a/koha-tmpl/opac-tmpl/lib/js-cookie/js.cookie-3.0.1.min.js (-1 / +2 lines)
Line 0 Link Here
0
- 
1
/*! js-cookie v3.0.1 | MIT */
2
!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:"/"})}));

Return to bug 29940