Bug 25890: Update sorting column for checkouts table
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / z3950_search.js
1 //z3950_search.js for Authorities, Bib records and Acquisitions module
2 function Import(Breeding, recordid, AuthType, FrameworkCode) {
3
4     if ( AuthType == false ) {
5         opener.document.location="../cataloguing/addbiblio.pl?biblionumber="+recordid+"&z3950=1&frameworkcode="+FrameworkCode+"&breedingid="+Breeding;
6     } else {
7         opener.document.location="../authorities/authorities.pl?breedingid="+Breeding+"&authtypecode="+AuthType+"&authid="+recordid;
8     }
9     window.close();
10     return false;
11
12 }
13
14 $( document ).ready( function() {
15
16     $( "#CheckAll" ).click( function() {
17         $( ".checkboxed" ).checkCheckboxes();
18         return false;
19     });
20     $( "#CheckNone" ).click( function() {
21         $( ".checkboxed" ).unCheckCheckboxes();
22         return false;
23     });
24
25     $( ".submit" ).on( "click", function() {
26         $( "body" ).css( "cursor", "wait" );
27     });
28     $( "[name='changepage_prev']" ).on( "click", function() {
29         var data_current_page_prev = $( this ).data( "currentpage" );
30         $( '#current_page' ).val( data_current_page_prev - 1 );
31         $( '#page_form' ).submit();
32     });
33     $( "[name='changepage_next']" ).on( "click", function() {
34         var data_current_page_next = $( this ).data( "currentpage" );
35         $( '#current_page' ).val( data_current_page_next + 1 );
36         $( '#page_form' ).submit();
37     });
38     $( "[name='changepage_goto']" ).on( "click", function() {
39         return validate_goto_page();
40     });
41     $( "#resetZ3950Search" ).click( function(e) {
42         e.preventDefault();
43         $( "form[name='f']" ).find( "input[type=text]" ).val( "" );
44     });
45     $( "form[name='f']" ).submit( function() {
46         if ( $( 'input[type=checkbox]' ).filter( ':checked' ).length == 0 ) {
47             alert( MSG_CHOOSE_Z3950 );
48             $( "body" ).css( "cursor", "default" );
49             return false;
50         } else {
51             return true;
52         }
53     });
54
55     /* Display actions menu anywhere the table is clicked */
56     /* Note: The templates where this is included must have a search results
57        table with the id "resultst" and "action" table cells with the class "actions" */
58     $("#resultst").on("click", "td", function(event){
59         var tgt = $(event.target);
60         var row = $(this).parent();
61         /* Remove highlight from all rows and add to the clicked row */
62         $("tr").removeClass("highlighted-row");
63         row.addClass("highlighted-row");
64         /* Remove any menus created on the fly for other rows */
65         $(".btn-wrapper").remove();
66
67         if( tgt.is("a") || tgt.hasClass("actions") ){
68             /* Don't show inline links for cells containing links of their own. */
69         } else {
70             event.stopPropagation();
71             /* Remove the "open" class from all dropup menus in case one is open */
72             $(".dropup").removeClass("open");
73             /* Create a clone of the Bootstrap dropup menu in the "Actions" column */
74             var menu_clone = $(".dropdown-menu", row)
75                 .clone()
76                 .addClass("menu-clone")
77                 .css({
78                     "display" : "block",
79                     "position" : "absolute",
80                     "top" : "auto",
81                     "bottom" : "100%",
82                     "right" : "auto",
83                     "left" : "0",
84                 });
85             /* Append the menu clone to the table cell which was clicked.
86                 The menu must first be wrapped in a block-level div to clear
87                 the table cell's text contents and then a relative-positioned
88                 div to allow the menu to be positioned correctly */
89             tgt.append(
90                 $('<div/>', {'class': 'btn-wrapper'}).append(
91                     $('<div/>', {'class': 'btn-group'}).append(
92                         menu_clone
93                     )
94                 )
95             );
96         }
97     });
98
99     $( "#resultst" ).on("click", ".previewMARC", function(e) {
100         e.preventDefault();
101         var ltitle = $( this ).text();
102         var page = $( this ).attr( "href" );
103         $( "#marcPreviewLabel" ).text( ltitle );
104         $( "#marcPreview .modal-body" ).load( page + " pre" );
105         $( '#marcPreview' ).modal( {show:true} );
106     });
107     $( "#marcPreview" ).on( "hidden", function() {
108         $( "#marcPreviewLabel" ).html( "" );
109         $( "#marcPreview .modal-body" ).html( "<div id='loading'><img src='" + interface + "/" + theme + "/img/spinner-small.gif' alt='' /> " + MSG_LOADING + "</div>" );
110     });
111     $( "#resultst" ).on("click", ".previewData", function(e) {
112         e.preventDefault();
113         var ltitle = $( this ).text();
114         var page = $( this ).attr( "href" );
115         $( "#dataPreviewLabel" ).text( ltitle );
116         $( "#dataPreview .modal-body" ).load( page + " div" );
117         $( '#dataPreview' ).modal( {show:true} );
118     });
119     $( "#dataPreview" ).on( "hidden", function() {
120         $( "#dataPreviewLabel" ).html( "" );
121         $( "#dataPreview .modal-body" ).html( "<div id='loading'><img src='" + interface + "/" + theme + "/img/spinner-small.gif' alt='' /> " + MSG_LOADING + "</div>" );
122     });
123     $( "#resultst" ).on("click", ".import_record", function(e) {
124         e.preventDefault();
125         var data_breedingid = $( this ).data( "breedingid" );
126         var data_headingcode = $( this ).data( "heading_code" );
127         var data_authid = $( this ).data( "authid" );
128         var data_biblionumber = $( this ).data( "biblionumber" );
129         var data_frameworkcode = $( this ).data( "frameworkcode" );
130         if ( data_headingcode == undefined ) {
131             Import( data_breedingid, data_biblionumber, false , data_frameworkcode );
132         } else {
133             Import( data_breedingid, data_authid, data_headingcode );
134         }
135         return false;
136     });
137
138 });