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.js (+147 lines)
Line 0 Link Here
1
/*! js-cookie v3.0.1 | MIT */
2
;
3
(function (global, factory) {
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
5
  typeof define === 'function' && define.amd ? define(factory) :
6
  (global = global || self, (function () {
7
    var current = global.Cookies;
8
    var exports = global.Cookies = factory();
9
    exports.noConflict = function () { global.Cookies = current; return exports; };
10
  }()));
11
}(this, (function () { 'use strict';
12
13
  /* eslint-disable no-var */
14
  function assign (target) {
15
    for (var i = 1; i < arguments.length; i++) {
16
      var source = arguments[i];
17
      for (var key in source) {
18
        target[key] = source[key];
19
      }
20
    }
21
    return target
22
  }
23
  /* eslint-enable no-var */
24
25
  /* eslint-disable no-var */
26
  var defaultConverter = {
27
    read: function (value) {
28
      if (value[0] === '"') {
29
        value = value.slice(1, -1);
30
      }
31
      return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
32
    },
33
    write: function (value) {
34
      return encodeURIComponent(value).replace(
35
        /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
36
        decodeURIComponent
37
      )
38
    }
39
  };
40
  /* eslint-enable no-var */
41
42
  /* eslint-disable no-var */
43
44
  function init (converter, defaultAttributes) {
45
    function set (key, value, attributes) {
46
      if (typeof document === 'undefined') {
47
        return
48
      }
49
50
      attributes = assign({}, defaultAttributes, attributes);
51
52
      if (typeof attributes.expires === 'number') {
53
        attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
54
      }
55
      if (attributes.expires) {
56
        attributes.expires = attributes.expires.toUTCString();
57
      }
58
59
      key = encodeURIComponent(key)
60
        .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
61
        .replace(/[()]/g, escape);
62
63
      var stringifiedAttributes = '';
64
      for (var attributeName in attributes) {
65
        if (!attributes[attributeName]) {
66
          continue
67
        }
68
69
        stringifiedAttributes += '; ' + attributeName;
70
71
        if (attributes[attributeName] === true) {
72
          continue
73
        }
74
75
        // Considers RFC 6265 section 5.2:
76
        // ...
77
        // 3.  If the remaining unparsed-attributes contains a %x3B (";")
78
        //     character:
79
        // Consume the characters of the unparsed-attributes up to,
80
        // not including, the first %x3B (";") character.
81
        // ...
82
        stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
83
      }
84
85
      return (document.cookie =
86
        key + '=' + converter.write(value, key) + stringifiedAttributes)
87
    }
88
89
    function get (key) {
90
      if (typeof document === 'undefined' || (arguments.length && !key)) {
91
        return
92
      }
93
94
      // To prevent the for loop in the first place assign an empty array
95
      // in case there are no cookies at all.
96
      var cookies = document.cookie ? document.cookie.split('; ') : [];
97
      var jar = {};
98
      for (var i = 0; i < cookies.length; i++) {
99
        var parts = cookies[i].split('=');
100
        var value = parts.slice(1).join('=');
101
102
        try {
103
          var foundKey = decodeURIComponent(parts[0]);
104
          jar[foundKey] = converter.read(value, foundKey);
105
106
          if (key === foundKey) {
107
            break
108
          }
109
        } catch (e) {}
110
      }
111
112
      return key ? jar[key] : jar
113
    }
114
115
    return Object.create(
116
      {
117
        set: set,
118
        get: get,
119
        remove: function (key, attributes) {
120
          set(
121
            key,
122
            '',
123
            assign({}, attributes, {
124
              expires: -1
125
            })
126
          );
127
        },
128
        withAttributes: function (attributes) {
129
          return init(this.converter, assign({}, this.attributes, attributes))
130
        },
131
        withConverter: function (converter) {
132
          return init(assign({}, this.converter, converter), this.attributes)
133
        }
134
      },
135
      {
136
        attributes: { value: Object.freeze(defaultAttributes) },
137
        converter: { value: Object.freeze(converter) }
138
      }
139
    )
140
  }
141
142
  var api = init(defaultConverter, { path: '/' });
143
  /* eslint-enable no-var */
144
145
  return api;
146
147
})));
(-)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