Bug 16522: (follow-up) MARC display templates and get_marc_host fixes
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / authorities_js.inc
1 <!-- authorities_js.inc -->
2 <script>
3
4 function mergeAuth(authid, summary) {
5     var alreadySelected = Cookies.get('auth_to_merge');
6     if (alreadySelected !== undefined) {
7         alreadySelected = JSON.parse(alreadySelected);
8         Cookies.remove('auth_to_merge');
9         var refstring = "";
10         if (typeof alreadySelected.mergereference !== 'undefined') {
11             refstring = "&mergereference=" + alreadySelected.mergereference;
12         }
13         window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring;
14     } else {
15         Cookies.set('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/', sameSite: 'Lax' });
16         showMergingInProgress();
17     }
18 }
19
20 function showMergingInProgress() {
21     var alreadySelected = Cookies.get('auth_to_merge');
22     if (alreadySelected !== undefined) {
23         alreadySelected = JSON.parse(alreadySelected);
24         $('#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>");
25         $('#cancel_merge').click(function(event) {
26             event.preventDefault();
27             Cookies.remove('auth_to_merge');
28             $('#merge_in_progress').empty();
29         });
30     } else {
31         $('#merge_in_progress').empty();
32     }
33 }
34
35 function confirm_deletion(id) {
36     var is_confirmed = confirm(_("Are you sure you want to delete this authority?"));
37     if( !id ){
38         id = "[% authid | html %]";
39     }
40     if (is_confirmed) {
41       window.location="authorities-home.pl?op=delete"
42           + "&authid=" + id
43           + "&type=intranet"
44           + "&authtypecode=[% authtypecode | html %]"
45           + "&marclist=[% marclist | html %]"
46           + "&and_or=[% and_or | html %]"
47           + "&excluding=[% excluding | html %]"
48           + "&operator=[% operator | html %]"
49           + "&orderby=[% orderby | html %]"
50           + "&value=[% value |uri %]"
51           + "&startfrom=[% startfrom | html %]"
52           + "&resultsperpage=[% resultsperpage | html %]"
53           + "&csrf_token=[% csrf_token | html %]";
54     }
55 }
56
57 $(document).ready(function () {
58     showMergingInProgress();
59     $('.merge_auth').click(function (event) {
60         event.preventDefault();
61         mergeAuth($(this).parents('tr').attr('data-authid'), $(this).parents('tr').find('div.authorizedheading').text());
62     });
63
64     $("#delAuth").click(function(){
65         confirm_deletion();
66         return false;
67     });
68
69     $("#z3950_new").click(function(e){
70         e.preventDefault();
71         window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
72     });
73
74     $("#z3950_replace").click(function(e){
75         e.preventDefault();
76         window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid | html %]","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
77     });
78
79     var searchType = '[% marclist | html %]';
80     if (searchType) {
81         if ('mainmainentry' == searchType) {
82             $("#header_search").tabs( "option", "active", 0 );
83         } else if ('mainentry' == searchType) {
84             $("#header_search").tabs( "option", "active", 1 );
85         } else if ('match' == searchType) {
86             $("#header_search").tabs( "option", "active", 2 );
87         } else if ('all' == searchType) {
88             $("#header_search").tabs( "option", "active", 3 );
89         }
90     }
91
92 });
93
94 </script>
95 <!-- / authorities_js.inc -->