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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/printslip.tt (-2 / +10 lines)
Lines 13-24 Link Here
13
[% IF stylesheet %]
13
[% IF stylesheet %]
14
<link rel="stylesheet" type="text/css" href="[% stylesheet | $raw %]" />
14
<link rel="stylesheet" type="text/css" href="[% stylesheet | $raw %]" />
15
[% END %]
15
[% END %]
16
16
<script>
17
    var Koha = {};
18
    function _(s) { return s } // dummy function for gettext
19
    const is_logged_in = [% IF logged_in_user %]true[% ELSE %]false[% END %]
20
</script>
17
<!-- JavaScript includes -->
21
<!-- JavaScript includes -->
22
[% IF lang && lang != 'en' %]
23
    [% Asset.js(lang _ '/js/locale_data.js') | $raw %]
24
[% END %]
25
[% Asset.js('js/Gettext.js') | $raw %]
26
[% Asset.js('js/i18n.js') | $raw %]
18
[% Asset.js("lib/jquery/jquery-3.6.0.min.js") | $raw %]
27
[% Asset.js("lib/jquery/jquery-3.6.0.min.js") | $raw %]
19
[% Asset.js("lib/jquery/jquery-migrate-3.3.2.min.js") | $raw %]
28
[% Asset.js("lib/jquery/jquery-migrate-3.3.2.min.js") | $raw %]
20
[% Asset.js("lib/fontfaceobserver/fontfaceobserver.min.js") | $raw %]
29
[% Asset.js("lib/fontfaceobserver/fontfaceobserver.min.js") | $raw %]
21
[% Asset.js("lib/enquire.min.js") | $raw %]
22
[% Asset.js("js/global.js") | $raw %]
30
[% Asset.js("js/global.js") | $raw %]
23
31
24
[% INCLUDE 'slip-print.inc' #printThenClose %]
32
[% INCLUDE 'slip-print.inc' #printThenClose %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/global.js (-120 / +172 lines)
Lines 1-88 Link Here
1
/* global enquire readCookie updateBasket delCookie __ */
1
/* global enquire readCookie updateBasket delCookie __ */
2
(function( w ){
2
(function (w) {
3
    // if the class is already set, the font has already been loaded
3
    // if the class is already set, the font has already been loaded
4
    if( w.document.documentElement.className.indexOf( "fonts-loaded" ) > -1 ){
4
    if (w.document.documentElement.className.indexOf("fonts-loaded") > -1) {
5
        return;
5
        return;
6
    }
6
    }
7
    var PrimaryFont = new w.FontFaceObserver( "NotoSans", {
7
    var PrimaryFont = new w.FontFaceObserver("NotoSans", {
8
        weight: 400
8
        weight: 400,
9
    });
9
    });
10
10
11
    PrimaryFont.load(null, 5000).then(function(){
11
    PrimaryFont.load(null, 5000).then(
12
        w.document.documentElement.className += " fonts-loaded";
12
        function () {
13
    }, function(){
13
            w.document.documentElement.className += " fonts-loaded";
14
        console.log("Failed");
14
        },
15
    });
15
        function () {
16
}( this ));
16
            // Could not load web font
17
        }
18
    );
19
})(this);
17
20
18
// http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery/5341855#5341855
21
// http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery/5341855#5341855
19
String.prototype.format = function() { return formatstr(this, arguments) }
22
String.prototype.format = function () {
23
    return formatstr(this, arguments);
24
};
20
function formatstr(str, col) {
25
function formatstr(str, col) {
21
    col = typeof col === 'object' ? col : Array.prototype.slice.call(arguments, 1);
26
    col =
27
        typeof col === "object"
28
            ? col
29
            : Array.prototype.slice.call(arguments, 1);
22
    var idx = 0;
30
    var idx = 0;
23
    return str.replace(/%%|%s|%(\d+)\$s/g, function (m, n) {
31
    return str.replace(/%%|%s|%(\d+)\$s/g, function (m, n) {
24
        if (m == "%%") { return "%"; }
32
        if (m == "%%") {
25
        if (m == "%s") { return col[idx++]; }
33
            return "%";
34
        }
35
        if (m == "%s") {
36
            return col[idx++];
37
        }
26
        return col[n];
38
        return col[n];
27
    });
39
    });
28
};
40
}
29
41
30
var HtmlCharsToEscape = {
42
var HtmlCharsToEscape = {
31
    '&': '&amp;',
43
    "&": "&amp;",
32
    '<': '&lt;',
44
    "<": "&lt;",
33
    '>': '&gt;'
45
    ">": "&gt;",
34
};
46
};
35
String.prototype.escapeHtml = function() {
47
String.prototype.escapeHtml = function () {
36
    return this.replace(/[&<>]/g, function(c) {
48
    return this.replace(/[&<>]/g, function (c) {
37
        return HtmlCharsToEscape[c] || c;
49
        return HtmlCharsToEscape[c] || c;
38
    });
50
    });
39
};
51
};
40
function escape_str(s){
52
function escape_str(s) {
41
    return s != null ? s.escapeHtml() : "";
53
    return s != null ? s.escapeHtml() : "";
42
}
54
}
43
55
44
function confirmDelete(message) {
56
function confirmDelete(message) {
45
    return (confirm(message) ? true : false);
57
    return confirm(message) ? true : false;
46
}
58
}
47
59
48
function Dopop(link) {
60
function Dopop(link) {
49
    newin=window.open(link,'popup','width=660,height=450,toolbar=false,scrollbars=yes,resizable=yes');
61
    newin = window.open(
62
        link,
63
        "popup",
64
        "width=660,height=450,toolbar=false,scrollbars=yes,resizable=yes"
65
    );
50
}
66
}
51
67
52
jQuery.fn.preventDoubleFormSubmit = function() {
68
jQuery.fn.preventDoubleFormSubmit = function () {
53
    jQuery(this).submit(function() {
69
    jQuery(this).submit(function () {
54
        if (this.beenSubmitted)
70
        if (this.beenSubmitted) return false;
55
            return false;
71
        else this.beenSubmitted = true;
56
        else
57
            this.beenSubmitted = true;
58
    });
72
    });
59
};
73
};
60
74
61
function prefixOf (s, tok) {
75
function prefixOf(s, tok) {
62
    var index = s.indexOf(tok);
76
    var index = s.indexOf(tok);
63
    return s.substring(0, index);
77
    return s.substring(0, index);
64
}
78
}
65
function suffixOf (s, tok) {
79
function suffixOf(s, tok) {
66
    var index = s.indexOf(tok);
80
    var index = s.indexOf(tok);
67
    return s.substring(index + 1);
81
    return s.substring(index + 1);
68
}
82
}
69
83
70
$("body").on("keypress", ".noEnterSubmit", function(e){
84
$("body").on("keypress", ".noEnterSubmit", function (e) {
71
    return checkEnter(e);
85
    return checkEnter(e);
72
});
86
});
73
87
74
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
88
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
75
function checkEnter(e){ //e is event object passed from function invocation
89
function checkEnter(e) {
90
    //e is event object passed from function invocation
76
    var characterCode; // literal character code will be stored in this variable
91
    var characterCode; // literal character code will be stored in this variable
77
    if(e && e.which){ //if which property of event object is supported (NN4)
92
    if (e && e.which) {
93
        //if which property of event object is supported (NN4)
78
        characterCode = e.which; //character code is contained in NN4's which property
94
        characterCode = e.which; //character code is contained in NN4's which property
79
    } else {
95
    } else {
80
        characterCode = e.keyCode; //character code is contained in IE's keyCode property
96
        characterCode = e.keyCode; //character code is contained in IE's keyCode property
81
    }
97
    }
82
    if( characterCode == 13 //if generated character code is equal to ascii 13 (if enter key)
98
    if (
83
        && e.target.nodeName == "INPUT"
99
        characterCode == 13 && //if generated character code is equal to ascii 13 (if enter key)
84
        && e.target.type != "submit" // Allow enter to submit using the submit button
100
        e.target.nodeName == "INPUT" &&
85
    ){
101
        e.target.type != "submit" // Allow enter to submit using the submit button
102
    ) {
86
        return false;
103
        return false;
87
    } else {
104
    } else {
88
        return true;
105
        return true;
Lines 91-99 function checkEnter(e){ //e is event object passed from function invocation Link Here
91
108
92
// Adapted from https://gist.github.com/jnormore/7418776
109
// Adapted from https://gist.github.com/jnormore/7418776
93
function confirmModal(message, title, yes_label, no_label, callback) {
110
function confirmModal(message, title, yes_label, no_label, callback) {
94
    $("#bootstrap-confirm-box-modal").data('confirm-yes', false);
111
    $("#bootstrap-confirm-box-modal").data("confirm-yes", false);
95
    if($("#bootstrap-confirm-box-modal").length == 0) {
112
    if ($("#bootstrap-confirm-box-modal").length == 0) {
96
        $("body").append('<div id="bootstrap-confirm-box-modal" tabindex="-1" role="dialog" aria-hidden="true" class="modal">\
113
        $("body").append(
114
            '<div id="bootstrap-confirm-box-modal" tabindex="-1" role="dialog" aria-hidden="true" class="modal">\
97
            <div class="modal-dialog">\
115
            <div class="modal-dialog">\
98
                <div class="modal-content">\
116
                <div class="modal-content">\
99
                    <div class="modal-header" style="min-height:40px;">\
117
                    <div class="modal-header" style="min-height:40px;">\
Lines 109-139 function confirmModal(message, title, yes_label, no_label, callback) { Link Here
109
                    </div>\
127
                    </div>\
110
                </div>\
128
                </div>\
111
            </div>\
129
            </div>\
112
        </div>');
130
        </div>'
113
        $("#bootstrap-confirm-box-modal-submit").on('click', function () {
131
        );
114
            $("#bootstrap-confirm-box-modal").data('confirm-yes', true);
132
        $("#bootstrap-confirm-box-modal-submit").on("click", function () {
115
            $("#bootstrap-confirm-box-modal").modal('hide');
133
            $("#bootstrap-confirm-box-modal").data("confirm-yes", true);
134
            $("#bootstrap-confirm-box-modal").modal("hide");
116
            return false;
135
            return false;
117
        });
136
        });
118
        $("#bootstrap-confirm-box-modal").on('hide.bs.modal', function () {
137
        $("#bootstrap-confirm-box-modal").on("hide.bs.modal", function () {
119
            if(callback) callback($("#bootstrap-confirm-box-modal").data('confirm-yes'));
138
            if (callback)
139
                callback($("#bootstrap-confirm-box-modal").data("confirm-yes"));
120
        });
140
        });
121
    }
141
    }
122
142
123
    $("#bootstrap-confirm-box-modal .modal-header h4").text( title || "" );
143
    $("#bootstrap-confirm-box-modal .modal-header h4").text(title || "");
124
    if( message && message != "" ){
144
    if (message && message != "") {
125
        $("#bootstrap-confirm-box-modal .modal-body").html( message || "" );
145
        $("#bootstrap-confirm-box-modal .modal-body").html(message || "");
126
    } else {
146
    } else {
127
        $("#bootstrap-confirm-box-modal .modal-body").remove();
147
        $("#bootstrap-confirm-box-modal .modal-body").remove();
128
    }
148
    }
129
    $("#bootstrap-confirm-box-modal-submit").text( yes_label || 'Confirm' );
149
    $("#bootstrap-confirm-box-modal-submit").text(yes_label || "Confirm");
130
    $("#bootstrap-confirm-box-modal-cancel").text( no_label || 'Cancel' );
150
    $("#bootstrap-confirm-box-modal-cancel").text(no_label || "Cancel");
131
    $("#bootstrap-confirm-box-modal").modal('show');
151
    $("#bootstrap-confirm-box-modal").modal("show");
132
}
152
}
133
153
134
135
// Function to check errors from AJAX requests
154
// Function to check errors from AJAX requests
136
const checkError = function(response) {
155
const checkError = function (response) {
137
    if (response.status >= 200 && response.status <= 299) {
156
    if (response.status >= 200 && response.status <= 299) {
138
        return response.json();
157
        return response.json();
139
    } else {
158
    } else {
Lines 144-235 const checkError = function(response) { Link Here
144
};
163
};
145
164
146
//Add jQuery :focusable selector
165
//Add jQuery :focusable selector
147
(function($) {
166
(function ($) {
148
    function visible(element) {
167
    function visible(element) {
149
        return $.expr.filters.visible(element) && !$(element).parents().addBack().filter(function() {
168
        return (
150
            return $.css(this, 'visibility') === 'hidden';
169
            $.expr.filters.visible(element) &&
151
        }).length;
170
            !$(element)
171
                .parents()
172
                .addBack()
173
                .filter(function () {
174
                    return $.css(this, "visibility") === "hidden";
175
                }).length
176
        );
152
    }
177
    }
153
178
154
    function focusable(element, isTabIndexNotNaN) {
179
    function focusable(element, isTabIndexNotNaN) {
155
        var map, mapName, img, nodeName = element.nodeName.toLowerCase();
180
        var map,
156
        if ('area' === nodeName) {
181
            mapName,
182
            img,
183
            nodeName = element.nodeName.toLowerCase();
184
        if ("area" === nodeName) {
157
            map = element.parentNode;
185
            map = element.parentNode;
158
            mapName = map.name;
186
            mapName = map.name;
159
            if (!element.href || !mapName || map.nodeName.toLowerCase() !== 'map') {
187
            if (
188
                !element.href ||
189
                !mapName ||
190
                map.nodeName.toLowerCase() !== "map"
191
            ) {
160
                return false;
192
                return false;
161
            }
193
            }
162
            img = $('img[usemap=#' + mapName + ']')[0];
194
            img = $("img[usemap=#" + mapName + "]")[0];
163
            return !!img && visible(img);
195
            return !!img && visible(img);
164
        }
196
        }
165
        return (/input|select|textarea|button|object/.test(nodeName) ?
197
        return (
166
                !element.disabled :
198
            (/input|select|textarea|button|object/.test(nodeName)
167
                'a' === nodeName ?
199
                ? !element.disabled
168
                element.href || isTabIndexNotNaN :
200
                : "a" === nodeName
169
                isTabIndexNotNaN) &&
201
                ? element.href || isTabIndexNotNaN
202
                : isTabIndexNotNaN) &&
170
            // the element and all of its ancestors must be visible
203
            // the element and all of its ancestors must be visible
171
            visible(element);
204
            visible(element)
205
        );
172
    }
206
    }
173
207
174
    $.extend($.expr[':'], {
208
    $.extend($.expr[":"], {
175
        focusable: function(element) {
209
        focusable: function (element) {
176
            return focusable(element, !isNaN($.attr(element, 'tabindex')));
210
            return focusable(element, !isNaN($.attr(element, "tabindex")));
177
        }
211
        },
178
    });
212
    });
179
})(jQuery);
213
})(jQuery);
180
214
181
enquire.register("screen and (max-width:608px)", {
215
if (typeof enquire == "object") {
182
    match : function() {
216
    enquire.register("screen and (max-width:608px)", {
183
        if($("body.scrollto").length > 0){
217
        match: function () {
184
            window.scrollTo( 0, $(".maincontent").offset().top );
218
            if ($("body.scrollto").length > 0) {
185
        }
219
                window.scrollTo(0, $(".maincontent").offset().top);
186
    }
220
            }
187
});
221
        },
222
    });
188
223
189
enquire.register("screen and (min-width:992px)", {
224
    enquire.register("screen and (min-width:992px)", {
190
    match : function() {
225
        match: function () {
191
        facetMenu( "show" );
226
            facetMenu("show");
192
    },
227
        },
193
    unmatch : function() {
228
        unmatch: function () {
194
        facetMenu( "hide" );
229
            facetMenu("hide");
195
    }
230
        },
196
});
231
    });
232
}
197
233
198
function facetMenu( action ){
234
function facetMenu(action) {
199
    if( action == "show" ){
235
    if (action == "show") {
200
        $(".menu-collapse-toggle").off("click", facetHandler );
236
        $(".menu-collapse-toggle").off("click", facetHandler);
201
        $(".menu-collapse").show();
237
        $(".menu-collapse").show();
202
    } else {
238
    } else {
203
        $(".menu-collapse-toggle").on("click", facetHandler ).removeClass("menu-open");
239
        $(".menu-collapse-toggle")
240
            .on("click", facetHandler)
241
            .removeClass("menu-open");
204
        $(".menu-collapse").hide();
242
        $(".menu-collapse").hide();
205
    }
243
    }
206
}
244
}
207
245
208
var facetHandler = function(e){
246
var facetHandler = function (e) {
209
    e.preventDefault();
247
    e.preventDefault();
210
    $(this).toggleClass("menu-open");
248
    $(this).toggleClass("menu-open");
211
    $(".menu-collapse").toggle();
249
    $(".menu-collapse").toggle();
212
};
250
};
213
251
214
$(document).ready(function(){
252
$(document).ready(function () {
215
    $("html").removeClass("no-js").addClass("js");
253
    $("html").removeClass("no-js").addClass("js");
216
    $(".close").click(function(){
254
    $(".close").click(function () {
217
        window.close();
255
        window.close();
218
    });
256
    });
219
    $(".focus").focus();
257
    $(".focus").focus();
220
    $(".js-show").show();
258
    $(".js-show").show();
221
    $(".js-hide").hide();
259
    $(".js-hide").hide();
222
260
223
    if( $(window).width() < 991 ){
261
    if ($(window).width() < 991) {
224
        facetMenu("hide");
262
        facetMenu("hide");
225
    }
263
    }
226
264
227
    // clear the basket when user logs out
265
    // clear the basket when user logs out
228
    $("#logout").click(function(){
266
    $("#logout").click(function () {
229
        var nameCookie = "bib_list";
267
        var nameCookie = "bib_list";
230
        var valCookie = readCookie(nameCookie);
268
        var valCookie = readCookie(nameCookie);
231
        if (valCookie) { // basket has contents
269
        if (valCookie) {
232
            updateBasket(0,null);
270
            // basket has contents
271
            updateBasket(0, null);
233
            delCookie(nameCookie);
272
            delCookie(nameCookie);
234
            return true;
273
            return true;
235
        } else {
274
        } else {
Lines 237-287 $(document).ready(function(){ Link Here
237
        }
276
        }
238
    });
277
    });
239
278
240
    $(".loginModal-trigger").on("click",function(e){
279
    $(".loginModal-trigger").on("click", function (e) {
241
        e.preventDefault();
280
        e.preventDefault();
242
        var button = $(this);
281
        var button = $(this);
243
        var context = button.data('return');
282
        var context = button.data("return");
244
        if ( context ) {
283
        if (context) {
245
            let return_url = window.location.pathname;
284
            let return_url = window.location.pathname;
246
            let params = window.location.search;
285
            let params = window.location.search;
247
            var tab = button.data('tab');
286
            var tab = button.data("tab");
248
            if ( tab ) {
287
            if (tab) {
249
                params = params ? params + '&tab=' + tab : '?tab=' + tab;
288
                params = params ? params + "&tab=" + tab : "?tab=" + tab;
250
            }
289
            }
251
            return_url += params;
290
            return_url += params;
252
            $('#modalAuth').append('<input type="hidden" name="return" value="'+return_url+'" />');
291
            $("#modalAuth").append(
292
                '<input type="hidden" name="return" value="' +
293
                    return_url +
294
                    '" />'
295
            );
253
        }
296
        }
254
        $("#loginModal").modal("show");
297
        $("#loginModal").modal("show");
255
    });
298
    });
256
    $("#loginModal").on("shown.bs.modal", function(){
299
    $("#loginModal").on("shown.bs.modal", function () {
257
        $("#muserid").focus();
300
        $("#muserid").focus();
258
    });
301
    });
259
302
260
    $("#scrolltocontent").click(function() {
303
    $("#scrolltocontent").click(function () {
261
        var content = $(".maincontent");
304
        var content = $(".maincontent");
262
        if (content.length > 0) {
305
        if (content.length > 0) {
263
            $('html,body').animate({
306
            $("html,body").animate(
264
                scrollTop: content.first().offset().top
307
                {
265
            },
308
                    scrollTop: content.first().offset().top,
266
            'slow');
309
                },
267
            content.first().find(':focusable').eq(0).focus();
310
                "slow"
311
            );
312
            content.first().find(":focusable").eq(0).focus();
268
        }
313
        }
269
    });
314
    });
270
315
271
    $('[data-toggle="tooltip"]').tooltip();
316
    if (typeof bootstrap == "object") {
317
        $('[data-toggle="tooltip"]').tooltip();
318
    }
272
319
273
    /* Scroll back to top button */
320
    /* Scroll back to top button */
274
    $("body").append('<button id="backtotop" class="btn btn-primary" aria-label="' + __("Back to top") + '"><i class="fa fa-arrow-up" aria-hidden="true" title="' + __("Scroll to the top of the page") + '"></i></button>');
321
    $("body").append(
322
        '<button id="backtotop" class="btn btn-primary" aria-label="' +
323
            __("Back to top") +
324
            '"><i class="fa fa-arrow-up" aria-hidden="true" title="' +
325
            __("Scroll to the top of the page") +
326
            '"></i></button>'
327
    );
275
    $("#backtotop").hide();
328
    $("#backtotop").hide();
276
    $(window).on("scroll", function(){
329
    $(window).on("scroll", function () {
277
        if ( $(window).scrollTop() < 300 ) {
330
        if ($(window).scrollTop() < 300) {
278
            $("#backtotop").fadeOut();
331
            $("#backtotop").fadeOut();
279
        } else {
332
        } else {
280
            $("#backtotop").fadeIn();
333
            $("#backtotop").fadeIn();
281
        }
334
        }
282
    });
335
    });
283
    $("#backtotop").on("click", function(e) {
336
    $("#backtotop").on("click", function (e) {
284
        e.preventDefault();
337
        e.preventDefault();
285
        $("html,body").animate({scrollTop: 0}, "slow");
338
        $("html,body").animate({ scrollTop: 0 }, "slow");
286
    });
339
    });
287
});
340
});
288
- 

Return to bug 36528