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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (-1 lines)
Lines 25-31 Link Here
25
[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
25
[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
26
<!-- koha core js -->
26
<!-- koha core js -->
27
[% Asset.js("js/staff-global.js") | $raw %]
27
[% Asset.js("js/staff-global.js") | $raw %]
28
[% Asset.js("js/commons.js") | $raw %]
29
28
30
[% INCLUDE 'validator-strings.inc' %]
29
[% INCLUDE 'validator-strings.inc' %]
31
[% IF ( IntranetUserJS ) %]
30
[% IF ( IntranetUserJS ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/commons.js (-73 lines)
Lines 1-73 Link Here
1
// Extends jQuery API
2
jQuery.extend({uniqueArray:function(array){
3
    return $.grep(array, function(el, index) {
4
        return index === $.inArray(el, array);
5
    });
6
}});
7
8
function removeByValue(arr, val) {
9
    for(var i=0; i<arr.length; i++) {
10
        if(arr[i] == val) {
11
            arr.splice(i, 1);
12
            break;
13
        }
14
    }
15
}
16
17
function paramOfUrl( url, param ) {
18
    param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
19
    var regexS = "[\\?&]"+param+"=([^&#]*)";
20
    var regex = new RegExp( regexS );
21
    var results = regex.exec( url );
22
    if( results == null ) {
23
        return "";
24
    } else {
25
        return results[1];
26
    }
27
}
28
29
function addBibToContext( bibnum ) {
30
    bibnum = parseInt(bibnum, 10);
31
    var bibnums = getContextBiblioNumbers();
32
    bibnums.push(bibnum);
33
    setContextBiblioNumbers( bibnums );
34
    setContextBiblioNumbers( $.uniqueArray( bibnums ) );
35
}
36
37
function delBibToContext( bibnum ) {
38
    var bibnums = getContextBiblioNumbers();
39
    removeByValue( bibnums, bibnum );
40
    setContextBiblioNumbers( $.uniqueArray( bibnums ) );
41
}
42
43
function setContextBiblioNumbers( bibnums ) {
44
    $.cookie('bibs_selected', JSON.stringify( bibnums ));
45
}
46
47
function getContextBiblioNumbers() {
48
    var r = $.cookie('bibs_selected');
49
    if ( r ) {
50
        return JSON.parse(r);
51
    }
52
    r = new Array();
53
    return r;
54
}
55
56
function resetSearchContext() {
57
    setContextBiblioNumbers( new Array() );
58
}
59
60
$(document).ready(function(){
61
    // forms with action leading to search
62
    $("form[action*='search.pl']").submit(function(){
63
        resetSearchContext();
64
    });
65
    // any link to launch a search except navigation links
66
    $("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){
67
        resetSearchContext();
68
    });
69
    // any link to a detail page from the results page.
70
    $("#bookbag_form a[href*='detail.pl?']").click(function(){
71
        resetSearchContext();
72
    });
73
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-1 / +75 lines)
Lines 1-4 Link Here
1
/* global shortcut delCookie delBasket Sticky */
1
/* global shortcut delCookie delBasket Sticky */
2
/* exported paramOfUrl addBibToContext delBibToContext */
2
if ( KOHA === undefined ) var KOHA = {};
3
if ( KOHA === undefined ) var KOHA = {};
3
4
4
function _(s) { return s; } // dummy function for gettext
5
function _(s) { return s; } // dummy function for gettext
Lines 119-124 $.fn.selectTabByID = function (tabID) { Link Here
119
        $.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" });
120
        $.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" });
120
    }
121
    }
121
    $.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" });
122
    $.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" });
123
124
    /* Search results browsing */
125
    /* forms with action leading to search */
126
    $("form[action*='search.pl']").submit(function(){
127
        resetSearchContext();
128
    });
129
    /* any link to launch a search except navigation links */
130
    $("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){
131
        resetSearchContext();
132
    });
133
    /* any link to a detail page from the results page. */
134
    $("#bookbag_form a[href*='detail.pl?']").click(function(){
135
        resetSearchContext();
136
    });
137
122
});
138
});
123
139
124
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
140
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
Lines 232-234 function keep_text(clicked_index) { Link Here
232
        searchboxes[i].value = persist;
248
        searchboxes[i].value = persist;
233
    }
249
    }
234
}
250
}
235
- 
251
252
// Extends jQuery API
253
jQuery.extend({uniqueArray:function(array){
254
    return $.grep(array, function(el, index) {
255
        return index === $.inArray(el, array);
256
    });
257
}});
258
259
function removeByValue(arr, val) {
260
    for(var i=0; i<arr.length; i++) {
261
        if(arr[i] == val) {
262
            arr.splice(i, 1);
263
            break;
264
        }
265
    }
266
}
267
268
function paramOfUrl( url, param ) {
269
    param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
270
    var regexS = "[\\?&]"+param+"=([^&#]*)";
271
    var regex = new RegExp( regexS );
272
    var results = regex.exec( url );
273
    if( results == null ) {
274
        return "";
275
    } else {
276
        return results[1];
277
    }
278
}
279
280
function addBibToContext( bibnum ) {
281
    bibnum = parseInt(bibnum, 10);
282
    var bibnums = getContextBiblioNumbers();
283
    bibnums.push(bibnum);
284
    setContextBiblioNumbers( bibnums );
285
    setContextBiblioNumbers( $.uniqueArray( bibnums ) );
286
}
287
288
function delBibToContext( bibnum ) {
289
    var bibnums = getContextBiblioNumbers();
290
    removeByValue( bibnums, bibnum );
291
    setContextBiblioNumbers( $.uniqueArray( bibnums ) );
292
}
293
294
function setContextBiblioNumbers( bibnums ) {
295
    $.cookie('bibs_selected', JSON.stringify( bibnums ));
296
}
297
298
function getContextBiblioNumbers() {
299
    var r = $.cookie('bibs_selected');
300
    if ( r ) {
301
        return JSON.parse(r);
302
    }
303
    r = new Array();
304
    return r;
305
}
306
307
function resetSearchContext() {
308
    setContextBiblioNumbers( new Array() );
309
}

Return to bug 25363