Koha/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc
Kyle M Hall 908096bf1c Bug 12295: fix Javascript error when merging authorities
Attempting to merge authorities results in the following error:
Uncaught SyntaxError: Unexpected token u authorities-home.pl:284
    showMergingInProgress authorities-home.pl:284
    (anonymous function) authorities-home.pl:297
    o jquery.js:2
    p.fireWith jquery.js:2
    e.extend.ready jquery.js:2
    c.addEventListener.B

This was the result of the upgrade of jquery-cookie by the patch
for bug 11369; newer versions of jquery-cookie changed the return of
$.cookie('foo') from null to undefined when the cookie is not present.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
No test plan, no errors.

Test
1. search some authorities
2. click merge, on browser dev console pops reported error message
'Unexpected token u authorities-home.pl...'
No way to marge auths
3. with pach applied, merging works again

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-06-05 12:16:39 -03:00

42 lines
1.8 KiB
PHP

<script type="text/javascript">
//<![CDATA[
function mergeAuth(authid, summary) {
var alreadySelected = $.cookie('auth_to_merge');
if (alreadySelected !== undefined) {
alreadySelected = JSON.parse(alreadySelected);
$.cookie('auth_to_merge', '', { 'path': '/', 'expires': -1 });
var refstring = "";
if (typeof alreadySelected.mergereference !== 'undefined') {
refstring = "&mergereference=" + alreadySelected.mergereference;
}
window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring;
} else {
$.cookie('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/' });
showMergingInProgress();
}
}
function showMergingInProgress() {
var alreadySelected = $.cookie('auth_to_merge');
if (alreadySelected !== undefined) {
alreadySelected = JSON.parse(alreadySelected);
$('#merge_in_progress').html(_("Merging with authority: ") + "<a href='detail.pl?authid=" + alreadySelected.authid + "'><span class='authorizedheading'>" + alreadySelected.summary + "</span> (" + alreadySelected.authid + ")</a> <a href='#' id='cancel_merge'>" + _("Cancel merge") + "</a>");
$('#cancel_merge').click(function(event) {
event.preventDefault();
$.cookie('auth_to_merge', '', { 'path': '/', 'expires': -1 });
$('#merge_in_progress').empty();
});
} else {
$('#merge_in_progress').empty();
}
}
$(document).ready(function () {
showMergingInProgress();
$('.merge_auth').click(function (event) {
event.preventDefault();
mergeAuth($(this).parents('tr').attr('data-authid'), $(this).parents('tr').find('div.authorizedheading').text());
});
});
//]]>
</script>