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

(-)a/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc (+2 lines)
Lines 39-44 Link Here
39
<script type="text/javascript" src="[% yuipath %]/menu/menu-min.js"></script>
39
<script type="text/javascript" src="[% yuipath %]/menu/menu-min.js"></script>
40
<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script>
40
<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script>
41
<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery-ui.js"></script>
41
<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery-ui.js"></script>
42
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.cookie.min.js"></script>
43
<script type="text/javascript" src="[% themelang %]/js/commons.js"></script>
42
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.hoverIntent.minified.js"></script>
44
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.hoverIntent.minified.js"></script>
43
<script type="text/javascript" src="[% themelang %]/js/script.js"></script>
45
<script type="text/javascript" src="[% themelang %]/js/script.js"></script>
44
[% IF ( OPACAmazonCoverImages ) %]
46
[% IF ( OPACAmazonCoverImages ) %]
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc (+2 lines)
Lines 35-40 Link Here
35
<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script>
35
<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script>
36
<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery-ui.js"></script>
36
<script type="text/javascript" src="[% themelang %]/lib/jquery/jquery-ui.js"></script>
37
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.hoverIntent.minified.js"></script>
37
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.hoverIntent.minified.js"></script>
38
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.cookie.min.js"></script>
39
<script type="text/javascript" src="[% themelang %]/js/commons.js"></script>
38
<script type="text/javascript" src="[% themelang %]/js/script.js"></script>
40
<script type="text/javascript" src="[% themelang %]/js/script.js"></script>
39
[% IF ( OPACAmazonCoverImages ) %]
41
[% IF ( OPACAmazonCoverImages ) %]
40
<script type="text/javascript" language="javascript">//<![CDATA[
42
<script type="text/javascript" language="javascript">//<![CDATA[
(-)a/koha-tmpl/opac-tmpl/prog/en/js/commons.js (+71 lines)
Line 0 Link Here
1
// Extends jQuery API
2
// http://www.wskidmore.com/downloads/jquery-uniqueArray.min.js
3
jQuery.extend({uniqueArray:function(e){if($.isArray(e)){var c={};var a,b;for(b=0,a=e.length;b<a;b++){var d=e[b].toString();if(c[d]){e.splice(b,1);a--;b--}else{c[d]=true}}}return(e)}});
4
5
function removeByValue(arr, val) {
6
    for(var i=0; i<arr.length; i++) {
7
        if(arr[i] == val) {
8
            arr.splice(i, 1);
9
            break;
10
        }
11
    }
12
}
13
14
function paramOfUrl( url, param ) {
15
    param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
16
    var regexS = "[\\?&]"+param+"=([^&#]*)";
17
    var regex = new RegExp( regexS );
18
    var results = regex.exec( url );
19
    if( results == null ) {
20
        return "";
21
    } else {
22
        return results[1];
23
    }
24
}
25
26
function addBibToContext( bibnum ) {
27
    var bibnums = getContextBiblioNumbers();
28
    bibnums.push(bibnum);
29
    setContextBiblioNumbers( bibnums );
30
    //var store = sessionStorage.getItem( "bibs_selected" );
31
}
32
33
function delBibToContext( bibnum ) {
34
    var bibnums = getContextBiblioNumbers();
35
    removeByValue( bibnums, bibnum );
36
    setContextBiblioNumbers( $.uniqueArray( bibnums ) );
37
}
38
39
function setContextBiblioNumbers( bibnums ) {
40
    //sessionStorage.setItem("bibs_selected", JSON.stringify( bibnums ) );
41
    $.cookie('bibs_selected', JSON.stringify( bibnums ));
42
}
43
44
function getContextBiblioNumbers() {
45
    //var r = sessionStorage.getItem("bibs_selected");
46
    var r = $.cookie('bibs_selected');
47
    if ( r ) {
48
        return JSON.parse(r);
49
    }
50
    r = new Array();
51
    return r;
52
}
53
54
function resetSearchContext() {
55
    setContextBiblioNumbers( new Array() );
56
}
57
58
$(document).ready(function(){
59
    // forms with action leading to search
60
    $("form[action*='opac-search.pl']").submit(function(){
61
        resetSearchContext();
62
    });
63
    // any link to launch a search except navigation links
64
    $("[href*='opac-search.pl?']").not(".nav").not('.searchwithcontext').click(function(){
65
        resetSearchContext();
66
    });
67
    // any link to a detail page from the results page.
68
    $("#bookbag_form a[href*='opac-detail.pl?']").click(function(){
69
        resetSearchContext();
70
    });
71
});
(-)a/koha-tmpl/opac-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js (+1 lines)
Line 0 Link Here
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<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}};
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (-5 / +12 lines)
Lines 154-159 Link Here
154
            renderPagIndexList(pag_index_ini, $("#listResults"));
154
            renderPagIndexList(pag_index_ini, $("#listResults"));
155
        }
155
        }
156
        $("#a_listResults").click(function(e) {
156
        $("#a_listResults").click(function(e) {
157
            $("#sidebar").toggle();
157
            if (arrPagination.length > 0) {
158
            if (arrPagination.length > 0) {
158
                e.preventDefault();
159
                e.preventDefault();
159
                var navigation = $(".pagination");
160
                var navigation = $(".pagination");
Lines 173-178 Link Here
173
            e.preventDefault();
174
            e.preventDefault();
174
            var navigation = $(".pagination");
175
            var navigation = $(".pagination");
175
            navigation.hide();
176
            navigation.hide();
177
            $("#sidebar").toggle();
176
        });
178
        });
177
    [% END %]
179
    [% END %]
178
180
Lines 285-292 function parseIDBJSON( json ) { Link Here
285
var timeoutRFW;
287
var timeoutRFW;
286
var totalPagItemList = 10;
288
var totalPagItemList = 10;
287
289
288
function rewindList()
290
function rewindList(e)
289
{
291
{
292
    e.preventDefault();
290
    var ul = $("#listResults");
293
    var ul = $("#listResults");
291
    var li_ini = ul.children(':first').next();
294
    var li_ini = ul.children(':first').next();
292
    var index_ini = pag_index_ini;
295
    var index_ini = pag_index_ini;
Lines 304-311 function rewindList() Link Here
304
    }
307
    }
305
}//rewindList
308
}//rewindList
306
309
307
function forwardList()
310
function forwardList(e)
308
{
311
{
312
    e.preventDefault();
309
    var ul = $("#listResults");
313
    var ul = $("#listResults");
310
    var li_ini = ul.children(':first').next();
314
    var li_ini = ul.children(':first').next();
311
    var index_ini = pag_index_ini;
315
    var index_ini = pag_index_ini;
Lines 336-342 function renderPagIndexList(index, ul) Link Here
336
    var ini = index - 1;
340
    var ini = index - 1;
337
    var end = ini + totalPagItemList - 1;
341
    var end = ini + totalPagItemList - 1;
338
    li = $("<li />");
342
    li = $("<li />");
339
    html = (index > pag_index_ini)?"<a href='#' id='rew_list_index' onclick='rewindList()' title='" + _("Click to rewind the list to") + " " + ini + " - " + end + "'>&laquo;</a>":"&laquo;";
343
    html = (index > pag_index_ini)?"<a href='#' id='rew_list_index' onclick='rewindList(event)' title='" + _("Click to rewind the list to") + " " + ini + " - " + end + "'>&laquo;</a>":"&laquo;";
340
    li.html(html);
344
    li.html(html);
341
    ul.append(li);
345
    ul.append(li);
342
    var title = "";
346
    var title = "";
Lines 358-364 function renderPagIndexList(index, ul) Link Here
358
    li = $("<li />");
362
    li = $("<li />");
359
    ini = index + 1;
363
    ini = index + 1;
360
    end = (arrPagination.length > index + totalPagItemList)?index + totalPagItemList:arrPagination.length - 1;
364
    end = (arrPagination.length > index + totalPagItemList)?index + totalPagItemList:arrPagination.length - 1;
361
    html = (end <= arrPagination.length - 1 && (end - index) >= totalPagItemList)?"<a href='#' id='fw_list_index' onclick='forwardList()' title='" + _("Click to forward the list to") + " " + ini + " - " + end + "'>&raquo;</a>":"&raquo;";
365
    html = (end <= arrPagination.length - 1 && (end - index) >= totalPagItemList)?"<a href='#' id='fw_list_index' onclick='forwardList(event)' title='" + _("Click to forward the list to") + " " + ini + " - " + end + "'>&raquo;</a>":"&raquo;";
362
    li.html(html);
366
    li.html(html);
363
    ul.append(li);
367
    ul.append(li);
364
}//renderPagIndexList
368
}//renderPagIndexList
Lines 1423-1429 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1423
        <div class="l_Results">[% IF ( listResults ) %]<a href="#" id="a_listResults" title="Show pagination list ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">Browse results</a>[% ELSE %]<span>Browse results</span>[% END %]</div>
1427
        <div class="l_Results">[% IF ( listResults ) %]<a href="#" id="a_listResults" title="Show pagination list ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">Browse results</a>[% ELSE %]<span>Browse results</span>[% END %]</div>
1424
        <ul class="pg_menu clearfix">
1428
        <ul class="pg_menu clearfix">
1425
            <li class="left_results">[% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; Previous</a>[% ELSE %]<span>Previous</span>[% END %]</li>
1429
            <li class="left_results">[% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; Previous</a>[% ELSE %]<span>Previous</span>[% END %]</li>
1426
            <li class="back_results"><a href="opac-search.pl?[% busc %]" title="Back to the results search list">Back to results</a></li>
1430
            <li class="back_results"><a href="opac-search.pl?[% busc %]" title="Back to the results search list" class="searchwithcontext">Back to results</a></li>
1427
            <li class="right_results">[% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">Next &raquo;</a>[% ELSE %]<span>Next</span>[% END %]</li>
1431
            <li class="right_results">[% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">Next &raquo;</a>[% ELSE %]<span>Next</span>[% END %]</li>
1428
        </ul>
1432
        </ul>
1429
        [% IF ( listResults ) %]
1433
        [% IF ( listResults ) %]
Lines 1440-1445 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1440
    </div>
1444
    </div>
1441
[% END %]
1445
[% END %]
1442
1446
1447
<div id="sidebar">
1443
[% INCLUDE 'opac-detail-sidebar.inc' %]
1448
[% INCLUDE 'opac-detail-sidebar.inc' %]
1444
        [% IF ( NovelistSelectProfile ) %] [% IF ( NovelistSelectView == 'right') %]
1449
        [% IF ( NovelistSelectProfile ) %] [% IF ( NovelistSelectView == 'right') %]
1445
         <div id="NovelistSelect">
1450
         <div id="NovelistSelect">
Lines 1468-1473 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1468
[% END %]
1473
[% END %]
1469
1474
1470
</div>
1475
</div>
1476
1477
</div>
1471
</div>
1478
</div>
1472
</div>
1479
</div>
1473
1480
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt (+48 lines)
Lines 109-114 function highlightOn() { Link Here
109
    $(".highlight_toggle").toggle();
109
    $(".highlight_toggle").toggle();
110
}
110
}
111
[% END %]
111
[% END %]
112
113
// Hide or show details link
114
// Update with first biblionumber in queue
115
function updateDetailsLink() {
116
    var bibnums = getContextBiblioNumbers();
117
    if ( bibnums.length > 0 ) {
118
        $(".details_link a").attr("href", "/cgi-bin/koha/opac-detail.pl?biblionumber=" + bibnums[0]);
119
        $(".details_link").show();
120
    } else {
121
        $(".details_link").hide();
122
    }
123
}
124
112
$(document).ready(function(){
125
$(document).ready(function(){
113
    [% IF ( OpacHighlightedWords ) %]
126
    [% IF ( OpacHighlightedWords ) %]
114
        $('a.title').each(function() {
127
        $('a.title').each(function() {
Lines 233-242 $(document).ready(function(){ Link Here
233
    }
246
    }
234
    $("#CheckAll").click(function(){
247
    $("#CheckAll").click(function(){
235
        $("#bookbag_form").checkCheckboxes();
248
        $("#bookbag_form").checkCheckboxes();
249
        $("#bookbag_form").find("input[type='checkbox'][name='biblionumber']").each(function(){
250
            $(this).change();
251
        } );
236
        return false;
252
        return false;
237
    });
253
    });
238
    $("#CheckNone").click(function(){
254
    $("#CheckNone").click(function(){
239
        $("#bookbag_form").unCheckCheckboxes();
255
        $("#bookbag_form").unCheckCheckboxes();
256
257
        $("#bookbag_form").find("input[type='checkbox'][name='biblionumber']").each(function(){
258
            $(this).change();
259
        } );
240
        return false;
260
        return false;
241
    });
261
    });
242
[% IF ( RequestOnOpac ) %]
262
[% IF ( RequestOnOpac ) %]
Lines 343-348 $(document).ready(function(){ Link Here
343
        });
363
        });
344
[% END %]
364
[% END %]
345
365
366
    $("#bookbag_form").ready(function(){
367
        $("#bookbag_form").unCheckCheckboxes();
368
        var bibnums = getContextBiblioNumbers();
369
        if (bibnums) {
370
            for (var i=0; i < bibnums.length; i++) {
371
                var id = ('#bib' + bibnums[i]);
372
                if ($(id)) {
373
                    $(id).attr('checked', true);
374
                }
375
            }
376
        }
377
        updateDetailsLink();
378
    });
379
380
    $("#bookbag_form :checkbox").change(function(){
381
        if ( $(this).is(':checked') == true ) {
382
            addBibToContext( $(this).val() );
383
        } else {
384
            delBibToContext( $(this).val() );
385
        }
386
        updateDetailsLink();
387
     });
388
389
    $(".details_link a").click(function(){
390
        var bibnums = getContextBiblioNumbers();
391
392
    });
346
});
393
});
347
394
348
//]]>
395
//]]>
Lines 482-487 $(document).ready(function(){ Link Here
482
                              Tag status here.
529
                              Tag status here.
483
                            </span>
530
                            </span>
484
            [% END %]
531
            [% END %]
532
            <span class="details_link" style="display:none" ><a href="#">Browse selected biblios &gt;&gt;</a></span>
485
        </div>
533
        </div>
486
534
487
        </td></tr>
535
        </td></tr>
(-)a/opac/opac-detail.pl (-4 / +18 lines)
Lines 24-29 use strict; Link Here
24
use warnings;
24
use warnings;
25
25
26
use CGI;
26
use CGI;
27
use JSON;
27
use C4::Auth qw(:DEFAULT get_session);
28
use C4::Auth qw(:DEFAULT get_session);
28
use C4::Branch;
29
use C4::Branch;
29
use C4::Koha;
30
use C4::Koha;
Lines 209-219 if ($session->param('busc')) { Link Here
209
            push @{$arrParamsBusc{$key}}, $value;
210
            push @{$arrParamsBusc{$key}}, $value;
210
        }
211
        }
211
    }
212
    }
213
212
    my $searchAgain = 0;
214
    my $searchAgain = 0;
215
    my ( $offset, $results_per_page );
216
217
    my $bibnums = $query->cookie('bibs_selected');
218
    $bibnums = JSON::from_json($bibnums);
219
    if ( scalar( @$bibnums ) ) {
220
        $arrParamsBusc{count} = scalar( @$bibnums );
221
        $arrParamsBusc{listBiblios} = join ',', @$bibnums;
222
        $results_per_page = $arrParamsBusc{count};
223
        $offset = 0;
224
    } else {
225
    $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
213
    my $count = C4::Context->preference('OPACnumSearchResults') || 20;
226
    my $count = C4::Context->preference('OPACnumSearchResults') || 20;
214
    my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
227
    $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
215
    $arrParamsBusc{'count'} = $results_per_page;
228
    $arrParamsBusc{'count'} = $results_per_page;
216
    my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
217
    # The value OPACnumSearchResults has changed and the search has to be rebuild
229
    # The value OPACnumSearchResults has changed and the search has to be rebuild
218
    if ($count != $results_per_page) {
230
    if ($count != $results_per_page) {
219
        if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
231
        if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
Lines 273-278 if ($session->param('busc')) { Link Here
273
            @arrBusc = split(/\&(?:amp;)?/, $newbusc);
285
            @arrBusc = split(/\&(?:amp;)?/, $newbusc);
274
        }
286
        }
275
    }
287
    }
288
289
    } # end if cookie bibs_selected exists
290
276
    my $buscParam = '';
291
    my $buscParam = '';
277
    my $j = 0;
292
    my $j = 0;
278
    # Rebuild the query for the button "back to results"
293
    # Rebuild the query for the button "back to results"
Lines 339-345 if ($session->param('busc')) { Link Here
339
        }
354
        }
340
        $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
355
        $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
341
    }
356
    }
342
    if ($searchAgain) {
357
    if ($searchAgain and not scalar( @$bibnums )) {
343
        my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
358
        my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
344
        my @newresults = @$newresultsRef;
359
        my @newresults = @$newresultsRef;
345
        # build the new listBiblios
360
        # build the new listBiblios
346
- 

Return to bug 10858