Bug 12150 - Use more javascript string formatting in intranet for translated strings.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / authorities_js.inc
1 <script type="text/javascript">
2 //<![CDATA[
3 function mergeAuth(authid, summary) {
4     var alreadySelected = $.cookie('auth_to_merge');
5     if (alreadySelected !== undefined) {
6         alreadySelected = JSON.parse(alreadySelected);
7         $.cookie('auth_to_merge', '', { 'path': '/', 'expires': -1 });
8         var refstring = "";
9         if (typeof alreadySelected.mergereference !== 'undefined') {
10             refstring = "&mergereference=" + alreadySelected.mergereference;
11         }
12         window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring;
13     } else {
14         $.cookie('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/' });
15         showMergingInProgress();
16     }
17 }
18
19 function showMergingInProgress() {
20     var alreadySelected = $.cookie('auth_to_merge');
21     if (alreadySelected !== undefined) {
22         alreadySelected = JSON.parse(alreadySelected);
23         $('#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>");
24         $('#cancel_merge').click(function(event) {
25             event.preventDefault();
26             $.cookie('auth_to_merge', '', { 'path': '/', 'expires': -1 });
27             $('#merge_in_progress').empty();
28         });
29     } else {
30         $('#merge_in_progress').empty();
31     }
32 }
33
34 $(document).ready(function () {
35     showMergingInProgress();
36     $('.merge_auth').click(function (event) {
37         event.preventDefault();
38         mergeAuth($(this).parents('tr').attr('data-authid'), $(this).parents('tr').find('div.authorizedheading').text());
39     });
40 });
41 //]]>
42 </script>