Bug 19502: (follow-up) Pass parameters to avoid making templates depend on search...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / authorities_js.inc
index cf4a072..7584c9f 100644 (file)
@@ -1,5 +1,5 @@
-<script type="text/javascript">
-//<![CDATA[
+<script>
+
 function mergeAuth(authid, summary) {
     var alreadySelected = $.cookie('auth_to_merge');
     if (alreadySelected !== undefined) {
@@ -31,12 +31,61 @@ function showMergingInProgress() {
     }
 }
 
+function confirm_deletion(id) {
+    var is_confirmed = confirm(_("Are you sure you want to delete this authority?"));
+    if( !id ){
+        id = "[% authid %]";
+    }
+    if (is_confirmed) {
+      window.location="authorities-home.pl?op=delete"
+          + "&authid=" + id
+          + "&type=intranet"
+          + "&authtypecode=[% authtypecode %]"
+          + "&marclist=[% marclist %]"
+          + "&and_or=[% and_or %]"
+          + "&excluding=[% excluding %]"
+          + "&operator=[% operator %]"
+          + "&orderby=[% orderby %]"
+          + "&value=[% value |url %]"
+          + "&startfrom=[% startfrom %]"
+          + "&resultsperpage=[% resultsperpage %]"
+          + "&csrf_token=[% csrf_token %]";
+    }
+}
+
 $(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());
     });
+
+    $("#delAuth").click(function(){
+        confirm_deletion();
+        return false;
+    });
+
+    $("#z3950_new").click(function(e){
+        e.preventDefault();
+        window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
+    });
+
+    $("#z3950_replace").click(function(e){
+        e.preventDefault();
+        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');
+    });
+
+    var searchType = '[% marclist %]';
+    if (searchType) {
+        if ('mainentry' == searchType) {
+            $("#header_search").tabs( "option", "selected", 0 );
+        } else if ('match' == searchType) {
+            $("#header_search").tabs( "option", "selected", 1 );
+        } else if ('all' == searchType) {
+            $("#header_search").tabs( "option", "selected", 2 );
+        }
+    }
+
 });
-//]]>
-</script>
+
+</script>
\ No newline at end of file