Bug 15360: Incorrect or mislabeled behavior on Authorities "New from Z39.50" Button
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / authorities_js.inc
1 <script>
2
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 function confirm_deletion(id) {
35     var is_confirmed = confirm(_("Are you sure you want to delete this authority?"));
36     if( !id ){
37         id = "[% authid %]";
38     }
39     if (is_confirmed) {
40       window.location="authorities-home.pl?op=delete"
41           + "&authid=" + id
42           + "&type=intranet"
43           + "&authtypecode=[% authtypecode %]"
44           + "&marclist=[% marclist %]"
45           + "&and_or=[% and_or %]"
46           + "&excluding=[% excluding %]"
47           + "&operator=[% operator %]"
48           + "&orderby=[% orderby %]"
49           + "&value=[% value |url %]"
50           + "&startfrom=[% startfrom %]"
51           + "&resultsperpage=[% resultsperpage %]"
52           + "&csrf_token=[% csrf_token %]";
53     }
54 }
55
56 $(document).ready(function () {
57     showMergingInProgress();
58     $('.merge_auth').click(function (event) {
59         event.preventDefault();
60         mergeAuth($(this).parents('tr').attr('data-authid'), $(this).parents('tr').find('div.authorizedheading').text());
61     });
62
63     $("#delAuth").click(function(){
64         confirm_deletion();
65         return false;
66     });
67
68     $("#z3950_new").click(function(e){
69         e.preventDefault();
70         window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
71     });
72
73     $("#z3950_replace").click(function(e){
74         e.preventDefault();
75         window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid %]","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
76     });
77
78     var searchType = '[% marclist %]';
79     if (searchType) {
80         if ('mainentry' == searchType) {
81             $("#header_search").tabs( "option", "selected", 0 );
82         } else if ('match' == searchType) {
83             $("#header_search").tabs( "option", "selected", 1 );
84         } else if ('all' == searchType) {
85             $("#header_search").tabs( "option", "selected", 2 );
86         }
87     }
88
89 });
90
91 </script>