| 1 |
|
| 2 |
/** |
| 3 |
* Get ID array of selected elements |
| 4 |
*/ |
| 5 |
function wpbc_get_selected_row_id() { |
| 6 |
|
| 7 |
var $table = jQuery( '.wpbc__wrap__booking_listing .wpbc_selectable_table' ); |
| 8 |
var checkboxes = $table.children( '.wpbc_selectable_body' ).filter( ':visible' ).find( '.check-column' ).find( ':checkbox' ); |
| 9 |
var selected_id = []; |
| 10 |
|
| 11 |
jQuery.each( |
| 12 |
checkboxes, |
| 13 |
function (key, checkbox) { |
| 14 |
if ( jQuery( checkbox ).is( ':checked' ) ) { |
| 15 |
var element_id = wpbc_get_row_id_from_element( checkbox ); |
| 16 |
selected_id.push( element_id ); |
| 17 |
} |
| 18 |
} |
| 19 |
); |
| 20 |
|
| 21 |
return selected_id; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
/** |
| 26 |
* Get ID of row, based on clciked element |
| 27 |
* |
| 28 |
* @param this_inbound_element - ususlly this |
| 29 |
* @returns {number} |
| 30 |
*/ |
| 31 |
function wpbc_get_row_id_from_element(this_inbound_element) { |
| 32 |
|
| 33 |
var element_id = jQuery( this_inbound_element ).closest( '.wpbc_listing_usual_row' ).attr( 'id' ); |
| 34 |
|
| 35 |
element_id = parseInt( element_id.replace( 'row_id_', '' ) ); |
| 36 |
|
| 37 |
return element_id; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
/** |
| 42 |
* == Booking Listing == Show or hide buttons on Actions toolbar at page, if we have some selected bookings. |
| 43 |
*/ |
| 44 |
function wpbc_show_hide_action_buttons_for_selected_bookings(){ |
| 45 |
|
| 46 |
var selected_rows_arr = wpbc_get_selected_row_id(); |
| 47 |
|
| 48 |
if ( selected_rows_arr.length > 0 ) { |
| 49 |
jQuery( '.hide_button_if_no_selection' ).show(); |
| 50 |
} else { |
| 51 |
jQuery( '.hide_button_if_no_selection' ).hide(); |
| 52 |
} |
| 53 |
} |