1 /* global __ total_pages */
2 //z3950_search.js for Authorities, Bib records and Acquisitions module
3 function Import(Breeding, recordid, AuthType, FrameworkCode) {
5 if ( AuthType == false ) {
6 opener.document.location="../cataloguing/addbiblio.pl?biblionumber="+recordid+"&z3950=1&frameworkcode="+FrameworkCode+"&breedingid="+Breeding;
8 opener.document.location="../authorities/authorities.pl?breedingid="+Breeding+"&authtypecode="+AuthType+"&authid="+recordid;
15 function validate_goto_page() {
16 var page = $('#goto_page').val();
18 alert( __("The page entered is not a number.") );
20 } else if (page < 1 || page > total_pages) {
21 alert( __("The page should be a number between 1 and %s.").format(total_pages) );
28 $( document ).ready( function() {
30 $( "#CheckAll" ).click( function(e) {
32 $( ".checkboxed input:checkbox" ).prop("checked", true);
34 $( "#CheckNone" ).click( function(e) {
36 $( ".checkboxed input:checkbox" ).prop("checked", false);
39 $( ".submit" ).on( "click", function() {
40 $( "body" ).css( "cursor", "wait" );
42 $( "[name='changepage_prev']" ).on( "click", function() {
43 var data_current_page_prev = $( this ).data( "currentpage" );
44 $( '#current_page' ).val( data_current_page_prev - 1 );
45 $( '#page_form' ).submit();
47 $( "[name='changepage_next']" ).on( "click", function() {
48 var data_current_page_next = $( this ).data( "currentpage" );
49 $( '#current_page' ).val( data_current_page_next + 1 );
50 $( '#page_form' ).submit();
52 $( "[name='changepage_goto']" ).on( "click", function() {
53 return validate_goto_page();
55 $( "#resetZ3950Search" ).click( function(e) {
57 $( "form[name='f']" ).find( "input[type=text]" ).val( "" );
59 $( "form[name='f']" ).submit( function() {
60 if ( $( 'input[type=checkbox]' ).filter( ':checked' ).length == 0 ) {
61 alert( __("Please choose at least one external target") );
62 $( "body" ).css( "cursor", "default" );
69 /* Display actions menu anywhere the table is clicked */
70 /* Note: The templates where this is included must have a search results
71 table with the id "resultst" and "action" table cells with the class "actions" */
72 $("#resultst").on("click", "td", function(event){
73 var tgt = $(event.target);
74 var row = $(this).parent();
75 /* Remove highlight from all rows and add to the clicked row */
76 $("tr").removeClass("highlighted-row");
77 row.addClass("highlighted-row");
78 /* Remove any menus created on the fly for other rows */
79 $(".btn-wrapper").remove();
81 if( tgt.is("a") || tgt.hasClass("actions") ){
82 /* Don't show inline links for cells containing links of their own. */
84 event.stopPropagation();
85 /* Remove the "open" class from all dropup menus in case one is open */
86 $(".dropup").removeClass("open");
87 /* Create a clone of the Bootstrap dropup menu in the "Actions" column */
88 var menu_clone = $(".dropdown-menu", row)
90 .addClass("menu-clone")
93 "position" : "absolute",
99 /* Append the menu clone to the table cell which was clicked.
100 The menu must first be wrapped in a block-level div to clear
101 the table cell's text contents and then a relative-positioned
102 div to allow the menu to be positioned correctly */
104 $('<div/>', {'class': 'btn-wrapper'}).append(
105 $('<div/>', {'class': 'btn-group'}).append(
113 $( "#resultst" ).on("click", ".previewMARC", function(e) {
115 var ltitle = $( this ).text();
116 var page = $( this ).attr( "href" );
117 $( "#marcPreviewLabel" ).text( ltitle );
118 $( "#marcPreview .modal-body" ).load( page + " pre" );
119 $( '#marcPreview' ).modal( {show:true} );
121 $( "#marcPreview" ).on( "hidden", function() {
122 $( "#marcPreviewLabel" ).html( "" );
123 $( "#marcPreview .modal-body" ).html( "<div id='loading'><img src='" + interface + "/" + theme + "/img/spinner-small.gif' alt='' /> " + __("Loading") + "</div>" );
125 $( "#resultst" ).on("click", ".previewData", function(e) {
127 var ltitle = $( this ).text();
128 var page = $( this ).attr( "href" );
129 $( "#dataPreviewLabel" ).text( ltitle );
130 $( "#dataPreview .modal-body" ).load( page + " div" );
131 $( '#dataPreview' ).modal( {show:true} );
133 $( "#dataPreview" ).on( "hidden", function() {
134 $( "#dataPreviewLabel" ).html( "" );
135 $( "#dataPreview .modal-body" ).html( "<div id='loading'><img src='" + interface + "/" + theme + "/img/spinner-small.gif' alt='' /> " + __("Loading") + "</div>" );
137 $( "#resultst" ).on("click", ".import_record", function(e) {
139 var data_breedingid = $( this ).data( "breedingid" );
140 var data_headingcode = $( this ).data( "heading_code" );
141 var data_authid = $( this ).data( "authid" );
142 var data_biblionumber = $( this ).data( "biblionumber" );
143 var data_frameworkcode = $( this ).data( "frameworkcode" );
144 if ( data_headingcode == undefined ) {
145 Import( data_breedingid, data_biblionumber, false , data_frameworkcode );
147 Import( data_breedingid, data_authid, data_headingcode );