| 1 |
/** |
| 2 |
* @version 1.0 |
| 3 |
* @package Booking Calendar |
| 4 |
* @subpackage BackEnd Main Script Lib |
| 5 |
* @category Scripts |
| 6 |
* |
| 7 |
* @author wpdevelop |
| 8 |
* @link https://wpbookingcalendar.com/ |
| 9 |
* @email info@wpbookingcalendar.com |
| 10 |
* |
| 11 |
* @modified 2014.09.10 |
| 12 |
*/ |
| 13 |
|
| 14 |
|
| 15 |
/** |
| 16 |
* Set Booking listing row as R e a d |
| 17 |
* |
| 18 |
* @param {type} booking_id |
| 19 |
* @returns {undefined} |
| 20 |
*/ |
| 21 |
function set_booking_row_read(booking_id){ |
| 22 |
if (booking_id == 0) { |
| 23 |
jQuery('.new-label').addClass('hidden_items'); |
| 24 |
jQuery('.bk-update-count').html( '0' ); |
| 25 |
} else { |
| 26 |
jQuery('#booking_mark_'+booking_id + '').addClass('hidden_items'); |
| 27 |
decrese_new_counter(); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
// FixIn: 9.6.3.5. |
| 33 |
|
| 34 |
/** |
| 35 |
* Decrease counter about new bookings |
| 36 |
* |
| 37 |
* @returns {undefined} |
| 38 |
*/ |
| 39 |
function decrese_new_counter () { |
| 40 |
var my_num = parseInt(jQuery('.bk-update-count').html()); |
| 41 |
if (my_num>0){ |
| 42 |
my_num = my_num - 1; |
| 43 |
jQuery('.bk-update-count').html(my_num); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
/** |
| 49 |
* Functions for the TimeLine |
| 50 |
* |
| 51 |
* @param {type} booking_id |
| 52 |
* @returns {undefined} |
| 53 |
*/ |
| 54 |
function set_booking_row_approved_in_timeline( booking_id ){ |
| 55 |
////Approve Add to [cell_bk_id_9] class [approved] -- TODO: Also in the [a_bk_id_9] - chnaged "data-content" attribute |
| 56 |
jQuery( '.cell_bk_id_' + booking_id ).addClass( 'approved' ); |
| 57 |
jQuery( '.timeline_info_bk_actionsbar_' + booking_id + ' .approve_bk_link' ).addClass( 'hidden_items' ); |
| 58 |
jQuery( '.timeline_info_bk_actionsbar_' + booking_id + ' .pending_bk_link' ).removeClass( 'hidden_items' ); |
| 59 |
|
| 60 |
set_booking_row_approved_in_flextimeline( booking_id ); |
| 61 |
} |
| 62 |
|
| 63 |
function set_booking_row_pending_in_timeline( booking_id ){ |
| 64 |
//Remove Remove from [cell_bk_id_9] class [approved] -- TODO: Also in the [a_bk_id_9] - chnaged "data-content" attribute |
| 65 |
jQuery( '.cell_bk_id_' + booking_id ).removeClass( 'approved' ); |
| 66 |
jQuery( '.timeline_info_bk_actionsbar_' + booking_id + ' .pending_bk_link' ).addClass( 'hidden_items' ); |
| 67 |
jQuery( '.timeline_info_bk_actionsbar_' + booking_id + ' .approve_bk_link' ).removeClass( 'hidden_items' ); |
| 68 |
|
| 69 |
set_booking_row_pending_in_flextimeline( booking_id ); |
| 70 |
} |
| 71 |
|
| 72 |
function set_booking_row_deleted_in_timeline( booking_id ){ |
| 73 |
// Remove in [cell_bk_id_9] classes [time_booked_in_day] |
| 74 |
// Delete element: [a_bk_id_] |
| 75 |
// TODO: Here is possible issue, if we are have several bookings per the same date and deleted only one |
| 76 |
|
| 77 |
// make actions on the elements, which are not have CLASS: "here_several_bk_id" |
| 78 |
// And have CLASS a_bk_id_ OR cell_bk_id_ |
| 79 |
jQuery( ':not(.here_several_bk_id).a_bk_id_' + booking_id ).fadeOut( 1000 ); |
| 80 |
jQuery( ':not(.here_several_bk_id).cell_bk_id_' + booking_id ).removeClass( 'time_booked_in_day' ); |
| 81 |
|
| 82 |
set_booking_row_deleted_in_flextimeline( booking_id ); |
| 83 |
} |
| 84 |
|
| 85 |
//FixIn: Flex TimeLine 1.0 |
| 86 |
|
| 87 |
function set_booking_row_approved_in_flextimeline( booking_id ){ |
| 88 |
jQuery( '.flex_tl_row_bar_show_bookings .booking_id.booking_id_' + booking_id ).removeClass( 'pending_booking' ); |
| 89 |
jQuery( '.flex_tl_row_bar_show_bookings .booking_id.booking_id_' + booking_id ).addClass( 'approved_booking' ); |
| 90 |
|
| 91 |
//Popover |
| 92 |
jQuery( '#wpbc-booking-id-' + booking_id + ' .flex-popover-labels-bar .label-pending').addClass( 'hidden_items' ); |
| 93 |
jQuery( '#wpbc-booking-id-' + booking_id + ' .flex-popover-labels-bar .label-approved').removeClass( 'hidden_items' ); |
| 94 |
//Dates |
| 95 |
jQuery( '#wpbc-booking-id-' + booking_id + ' .field-booking-date').addClass( 'approved' ); |
| 96 |
} |
| 97 |
|
| 98 |
function set_booking_row_pending_in_flextimeline( booking_id ){ |
| 99 |
jQuery( '.flex_tl_row_bar_show_bookings .booking_id.booking_id_' + booking_id ).removeClass( 'approved_booking' ); |
| 100 |
jQuery( '.flex_tl_row_bar_show_bookings .booking_id.booking_id_' + booking_id ).addClass( 'pending_booking' ); |
| 101 |
|
| 102 |
//Popover |
| 103 |
jQuery( '#wpbc-booking-id-' + booking_id + ' .flex-popover-labels-bar .label-pending').removeClass( 'hidden_items' ); |
| 104 |
jQuery( '#wpbc-booking-id-' + booking_id + ' .flex-popover-labels-bar .label-approved').addClass( 'hidden_items' ); |
| 105 |
//Dates |
| 106 |
jQuery( '#wpbc-booking-id-' + booking_id + ' .field-booking-date').removeClass( 'approved' ); |
| 107 |
} |
| 108 |
|
| 109 |
function set_booking_row_deleted_in_flextimeline( booking_id ){ |
| 110 |
|
| 111 |
jQuery( '.flex_tl_row_bar_show_bookings .booking_id.booking_id_' + booking_id ).fadeOut( 1000 ); |
| 112 |
jQuery( '.flex_tl_row_bar_show_booking_titles .in_cell_date_container_show_booking_titles.booking_id_' + booking_id ).fadeOut( 1000 ); |
| 113 |
|
| 114 |
//jQuery( '.flex_timeline_frame .popover' ) |
| 115 |
//Deprecated: FixIn: 9.0.1.1.1 |
| 116 |
// if ( 'function' === typeof( jQuery( ".popover_click.popover_bottom" ).popover ) ) //FixIn: 7.0.1.2 - 2016-12-10 |
| 117 |
// jQuery( '.popover_click.popover_bottom' ).popover( 'hide' ); //Hide all opned popovers |
| 118 |
|
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
// Set Booking listing R O W Approved |
| 123 |
function set_booking_row_approved(booking_id){ |
| 124 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-approved').removeClass('hidden_items'); |
| 125 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-pending').addClass('hidden_items'); |
| 126 |
|
| 127 |
jQuery('#booking_row_'+booking_id + ' .booking-dates .field-booking-date').addClass('approved'); |
| 128 |
|
| 129 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .approve_bk_link').addClass('hidden_items'); |
| 130 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .pending_bk_link').removeClass('hidden_items'); |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
// Set Booking listing R O W Pending |
| 135 |
function set_booking_row_pending(booking_id){ |
| 136 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-approved').addClass('hidden_items'); |
| 137 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-pending').removeClass('hidden_items'); |
| 138 |
|
| 139 |
jQuery('#booking_row_'+booking_id + ' .booking-dates .field-booking-date').removeClass('approved'); |
| 140 |
|
| 141 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .approve_bk_link').removeClass('hidden_items'); |
| 142 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .pending_bk_link').addClass('hidden_items'); |
| 143 |
|
| 144 |
} |
| 145 |
|
| 146 |
// Remove Booking listing R O W |
| 147 |
function set_booking_row_deleted(booking_id){ |
| 148 |
jQuery('#booking_row_'+booking_id).fadeOut(1000); |
| 149 |
jQuery('#gcal_imported_events_id_'+booking_id).remove(); |
| 150 |
} |
| 151 |
|
| 152 |
// FixIn: 9.6.3.5. |
| 153 |
|
| 154 |
// Set in Booking listing R O W new Remark in hint |
| 155 |
function set_booking_row_payment_status(booking_id, payment_status, payment_status_show){ |
| 156 |
|
| 157 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-payment-status').removeClass('label-danger'); |
| 158 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-payment-status').removeClass('label-success'); |
| 159 |
|
| 160 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-payment-status').html(payment_status_show); |
| 161 |
|
| 162 |
if (payment_status == 'OK') { |
| 163 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-payment-status').addClass('label-success'); |
| 164 |
} else if (payment_status == '') { |
| 165 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-payment-status').addClass('label-danger'); |
| 166 |
} else { |
| 167 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-payment-status').addClass('label-danger'); |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
// FixIn: 9.6.3.5. |
| 174 |
|
| 175 |
//FixIn: 5.4.5 |
| 176 |
/** |
| 177 |
* Get selected Locale of booking in Booking Listing page. |
| 178 |
* |
| 179 |
* @param booking_id Booking ID 10 |
| 180 |
* @param wpdev_active_locale Active Locale in system 'en_US' |
| 181 |
* @returns {string} Locale 'de_DE' |
| 182 |
*/ |
| 183 |
function wpbc_get_selected_locale( booking_id, wpdev_active_locale ){ |
| 184 |
|
| 185 |
var id_to_check = "" + booking_id; |
| 186 |
if ( -1 == id_to_check.indexOf( '|' ) ){ // Not found | |
| 187 |
var selected_locale = jQuery( '#locale_for_booking' + booking_id ).val(); |
| 188 |
|
| 189 |
if ( (selected_locale != '') && (typeof (selected_locale) !== 'undefined') ){ |
| 190 |
wpdev_active_locale = selected_locale; |
| 191 |
} |
| 192 |
} |
| 193 |
return wpdev_active_locale; |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
// Approve or set Pending booking |
| 198 |
function approve_unapprove_booking(booking_id, is_approve_or_pending, user_id, wpdev_active_locale, is_send_emeils ) { |
| 199 |
|
| 200 |
//FixIn: 5.4.5 |
| 201 |
wpdev_active_locale = wpbc_get_selected_locale(booking_id, wpdev_active_locale ); |
| 202 |
|
| 203 |
if ( booking_id !='' ) { |
| 204 |
|
| 205 |
var ajax_type_action = 'UPDATE_APPROVE'; |
| 206 |
var denyreason = ''; |
| 207 |
if ( is_send_emeils == 1 ) { |
| 208 |
if ( jQuery('#is_send_email_for_pending').length ) { |
| 209 |
is_send_emeils = jQuery( '#is_send_email_for_pending' ).is( ':checked' ); // FixIn: 8.7.9.5. |
| 210 |
if ( false === is_send_emeils ) { is_send_emeils = 0; } |
| 211 |
else { is_send_emeils = 1; } |
| 212 |
} |
| 213 |
if ( jQuery('#denyreason').length ) |
| 214 |
denyreason = jQuery('#denyreason').val(); |
| 215 |
} else { |
| 216 |
is_send_emeils = 0; |
| 217 |
} |
| 218 |
|
| 219 |
wpbc_admin_show_message_processing( '' ); |
| 220 |
|
| 221 |
jQuery.ajax({ // Start Ajax Sending |
| 222 |
url: wpbc_url_ajax, |
| 223 |
type:'POST', |
| 224 |
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );}, |
| 225 |
error:function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;console.error( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {console.error( 'Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}}, |
| 226 |
// beforeSend: someFunction, |
| 227 |
data:{ |
| 228 |
// ajax_action : ajax_type_action, // Action |
| 229 |
action : ajax_type_action, // Action |
| 230 |
booking_id : booking_id, // ID of Booking - separator | |
| 231 |
is_approve_or_pending : is_approve_or_pending, // Approve: 1, Reject: 0 |
| 232 |
is_send_emeils : is_send_emeils, |
| 233 |
denyreason: denyreason, |
| 234 |
user_id: user_id, |
| 235 |
wpdev_active_locale:wpdev_active_locale, |
| 236 |
wpbc_nonce: document.getElementById('wpbc_admin_panel_nonce').value |
| 237 |
} |
| 238 |
}); |
| 239 |
return false; |
| 240 |
} |
| 241 |
|
| 242 |
return true; |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
//FixIn: 6.1.1.10 |
| 247 |
// Set Booking listing R O W Trash |
| 248 |
function set_booking_row_trash( booking_id ){ |
| 249 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-trash').removeClass('hidden_items'); |
| 250 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .trash_bk_link').addClass('hidden_items'); |
| 251 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .restore_bk_link').removeClass('hidden_items'); |
| 252 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .delete_bk_link').removeClass('hidden_items'); |
| 253 |
|
| 254 |
// TimeLine |
| 255 |
jQuery('.cell_bk_id_'+booking_id).addClass('booking_trash'); |
| 256 |
jQuery('.timeline_info_bk_actionsbar_'+booking_id + ' .trash_bk_link').addClass('hidden_items'); |
| 257 |
jQuery('.timeline_info_bk_actionsbar_'+booking_id + ' .restore_bk_link').removeClass('hidden_items'); |
| 258 |
jQuery('.timeline_info_bk_actionsbar_'+booking_id + ' .delete_bk_link').removeClass('hidden_items'); |
| 259 |
|
| 260 |
jQuery('#wpbc-booking-id-'+booking_id + ' .label-trash').removeClass('hidden_items'); |
| 261 |
|
| 262 |
set_booking_row_deleted_in_flextimeline( booking_id ); //FixIn: Flex TimeLine 1.0 |
| 263 |
} |
| 264 |
|
| 265 |
//FixIn: 6.1.1.10 |
| 266 |
// Set Booking listing R O W Restore |
| 267 |
function set_booking_row_restore( booking_id ){ |
| 268 |
jQuery('#booking_row_'+booking_id + ' .booking-labels .label-trash').addClass('hidden_items'); |
| 269 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .trash_bk_link').removeClass('hidden_items'); |
| 270 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .restore_bk_link').addClass('hidden_items'); |
| 271 |
jQuery('#booking_row_'+booking_id + ' .booking-actions .delete_bk_link').addClass('hidden_items'); |
| 272 |
|
| 273 |
// TimeLine |
| 274 |
jQuery('.cell_bk_id_'+booking_id).removeClass('booking_trash'); |
| 275 |
jQuery('.timeline_info_bk_actionsbar_'+booking_id + ' .trash_bk_link').removeClass('hidden_items'); |
| 276 |
jQuery('.timeline_info_bk_actionsbar_'+booking_id + ' .restore_bk_link').addClass('hidden_items'); |
| 277 |
jQuery('.timeline_info_bk_actionsbar_'+booking_id + ' .delete_bk_link').addClass('hidden_items'); |
| 278 |
|
| 279 |
jQuery('#wpbc-booking-id-'+booking_id + ' .label-trash').addClass('hidden_items'); |
| 280 |
} |
| 281 |
|
| 282 |
//FixIn: 6.1.1.10 |
| 283 |
// Trash or restore booking |
| 284 |
function trash__restore_booking( is_trash, booking_id, user_id, wpdev_active_locale, is_send_emeils ) { |
| 285 |
|
| 286 |
///////////////////////////////////////////////////////////////////// |
| 287 |
//FixIn: 5.4.5 |
| 288 |
wpdev_active_locale = wpbc_get_selected_locale(booking_id, wpdev_active_locale ); |
| 289 |
|
| 290 |
if ( booking_id !='' ) { |
| 291 |
|
| 292 |
var ajax_type_action = 'TRASH_RESTORE'; |
| 293 |
var denyreason = ''; |
| 294 |
if (is_send_emeils == 1) { |
| 295 |
if ( jQuery('#is_send_email_for_pending').length ) { |
| 296 |
is_send_emeils = jQuery( '#is_send_email_for_pending' ).is( ':checked' ); // FixIn: 8.7.9.5. |
| 297 |
if ( false === is_send_emeils ) { is_send_emeils = 0; } |
| 298 |
else { is_send_emeils = 1; } |
| 299 |
} |
| 300 |
if ( jQuery('#denyreason').length ) |
| 301 |
denyreason = jQuery('#denyreason').val(); |
| 302 |
} else { |
| 303 |
is_send_emeils = 0; |
| 304 |
} |
| 305 |
|
| 306 |
wpbc_admin_show_message_processing( '' ); |
| 307 |
|
| 308 |
jQuery.ajax({ // Start Ajax Sending |
| 309 |
url: wpbc_url_ajax, |
| 310 |
type:'POST', |
| 311 |
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );}, |
| 312 |
error:function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;console.error( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {console.error( 'Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}}, |
| 313 |
// beforeSend: someFunction, |
| 314 |
data:{ |
| 315 |
//ajax_action : ajax_type_action, // Action |
| 316 |
action : ajax_type_action, // Action |
| 317 |
booking_id : booking_id, // ID of Booking - separator | |
| 318 |
is_send_emeils : is_send_emeils, |
| 319 |
denyreason: denyreason, |
| 320 |
user_id: user_id, |
| 321 |
wpdev_active_locale:wpdev_active_locale, |
| 322 |
is_trash:is_trash, |
| 323 |
wpbc_nonce: document.getElementById('wpbc_admin_panel_nonce').value |
| 324 |
} |
| 325 |
}); |
| 326 |
return false; |
| 327 |
} |
| 328 |
|
| 329 |
return true; |
| 330 |
|
| 331 |
} |
| 332 |
|
| 333 |
// Delete booking |
| 334 |
function delete_booking(booking_id, user_id, wpdev_active_locale, is_send_emeils ) { |
| 335 |
|
| 336 |
//FixIn: 5.4.5 |
| 337 |
wpdev_active_locale = wpbc_get_selected_locale(booking_id, wpdev_active_locale ); |
| 338 |
|
| 339 |
if ( booking_id !='' ) { |
| 340 |
|
| 341 |
var ajax_type_action = 'DELETE_APPROVE'; |
| 342 |
var denyreason = ''; |
| 343 |
if (is_send_emeils == 1) { |
| 344 |
if ( jQuery('#is_send_email_for_pending').length ) { |
| 345 |
is_send_emeils = jQuery( '#is_send_email_for_pending' ).is( ':checked' ); // FixIn: 8.7.9.5. |
| 346 |
if ( false === is_send_emeils ) { is_send_emeils = 0; } |
| 347 |
else { is_send_emeils = 1; } |
| 348 |
} |
| 349 |
if ( jQuery('#denyreason').length ) |
| 350 |
denyreason = jQuery('#denyreason').val(); |
| 351 |
} else { |
| 352 |
is_send_emeils = 0; |
| 353 |
} |
| 354 |
|
| 355 |
wpbc_admin_show_message_processing( '' ); |
| 356 |
|
| 357 |
jQuery.ajax({ // Start Ajax Sending |
| 358 |
url: wpbc_url_ajax, |
| 359 |
type:'POST', |
| 360 |
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );}, |
| 361 |
error:function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;console.error( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {console.error( 'Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}}, |
| 362 |
// beforeSend: someFunction, |
| 363 |
data:{ |
| 364 |
//ajax_action : ajax_type_action, // Action |
| 365 |
action : ajax_type_action, // Action |
| 366 |
booking_id : booking_id, // ID of Booking - separator | |
| 367 |
is_send_emeils : is_send_emeils, |
| 368 |
denyreason: denyreason, |
| 369 |
user_id: user_id, |
| 370 |
wpdev_active_locale:wpdev_active_locale, |
| 371 |
wpbc_nonce: document.getElementById('wpbc_admin_panel_nonce').value |
| 372 |
} |
| 373 |
}); |
| 374 |
return false; |
| 375 |
} |
| 376 |
|
| 377 |
return true; |
| 378 |
} |
| 379 |
|
| 380 |
// FixIn: 9.6.3.5. |
| 381 |
|
| 382 |
// Get Selected rows in imported Events list |
| 383 |
function get_selected_bookings_id_in_this_list( list_tag, skip_id_length ) { |
| 384 |
|
| 385 |
var checkedd = jQuery( list_tag + ":checked" ); |
| 386 |
var id_for_approve = ""; |
| 387 |
|
| 388 |
// get all IDs |
| 389 |
checkedd.each(function(){ |
| 390 |
var id_c = jQuery(this).attr('id'); |
| 391 |
id_c = id_c.substr(skip_id_length,id_c.length-skip_id_length); |
| 392 |
id_for_approve += id_c + "|"; |
| 393 |
}); |
| 394 |
|
| 395 |
if ( id_for_approve.length > 1 ) |
| 396 |
id_for_approve = id_for_approve.substr(0,id_for_approve.length-1); //delete last "|" |
| 397 |
|
| 398 |
return id_for_approve ; |
| 399 |
|
| 400 |
} |
| 401 |
|
| 402 |
// FixIn: 9.6.3.5. |
| 403 |
|
| 404 |
|
| 405 |
/** |
| 406 |
* Selections of several checkboxes like in gMail with shift :) |
| 407 |
* Need to have this structure: |
| 408 |
* .wpbc_selectable_table |
| 409 |
* .wpbc_selectable_head |
| 410 |
* .check-column |
| 411 |
* :checkbox |
| 412 |
* .wpbc_selectable_body |
| 413 |
* .wpbc_row |
| 414 |
* .check-column |
| 415 |
* :checkbox |
| 416 |
* .wpbc_selectable_foot |
| 417 |
* .check-column |
| 418 |
* :checkbox |
| 419 |
*/ |
| 420 |
( function( $ ){ |
| 421 |
$( document ).ready(function(){ |
| 422 |
|
| 423 |
var checks, first, last, checked, sliced, lastClicked = false; |
| 424 |
|
| 425 |
// check all checkboxes |
| 426 |
$('.wpbc_selectable_body').find('.check-column').find(':checkbox').on( 'click', function(e) { // FixIn: 8.7.11.12. |
| 427 |
if ( 'undefined' == e.shiftKey ) { return true; } |
| 428 |
if ( e.shiftKey ) { |
| 429 |
if ( !lastClicked ) { return true; } |
| 430 |
//checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' ); |
| 431 |
checks = $( lastClicked ).closest( '.wpbc_selectable_body' ).find( ':checkbox' ).filter( ':visible:enabled' ); |
| 432 |
first = checks.index( lastClicked ); |
| 433 |
last = checks.index( this ); |
| 434 |
checked = $(this).prop('checked'); |
| 435 |
if ( 0 < first && 0 < last && first != last ) { |
| 436 |
sliced = ( last > first ) ? checks.slice( first, last ) : checks.slice( last, first ); |
| 437 |
sliced.prop( 'checked', function() { |
| 438 |
if ( $(this).closest('.wpbc_row').is(':visible') ) |
| 439 |
return checked; |
| 440 |
|
| 441 |
return false; |
| 442 |
}); |
| 443 |
} |
| 444 |
} |
| 445 |
lastClicked = this; |
| 446 |
|
| 447 |
// toggle "check all" checkboxes |
| 448 |
var unchecked = $(this).closest('.wpbc_selectable_body').find(':checkbox').filter(':visible:enabled').not(':checked'); |
| 449 |
// FixIn: 8.8.1.15. |
| 450 |
$(this).closest('.wpbc_selectable_table').find('.wpbc_selectable_head, .wpbc_selectable_foot').find(':checkbox').prop('checked', function() { |
| 451 |
return ( 0 === unchecked.length ); |
| 452 |
}); |
| 453 |
|
| 454 |
|
| 455 |
// Disable text selection while pressing 'shift' |
| 456 |
document.getSelection().removeAllRanges(); // FixIn: 8.7.6.8. |
| 457 |
|
| 458 |
return true; |
| 459 |
}); |
| 460 |
|
| 461 |
// FixIn: 9.9.0.7. |
| 462 |
$('.wpbc_selectable_body').find('.check-column').find(':checkbox').on( 'change', function(e) { |
| 463 |
if ( jQuery( this ).is( ':checked' ) ){ |
| 464 |
jQuery( this ).closest( '.wpbc_flextable_row' ).addClass( 'wpbc_flextable_row_selected' ); |
| 465 |
} else { |
| 466 |
jQuery( this ).closest( '.wpbc_flextable_row' ).removeClass( 'wpbc_flextable_row_selected' ); |
| 467 |
} |
| 468 |
}); |
| 469 |
|
| 470 |
$('.wpbc_selectable_head, .wpbc_selectable_foot').find('.check-column :checkbox').on( 'click.wp-toggle-checkboxes', function( event ) { |
| 471 |
var $this = $(this), |
| 472 |
$table = $this.closest( '.wpbc_selectable_table' ), |
| 473 |
controlChecked = $this.prop('checked'), |
| 474 |
toggle = event.shiftKey || $this.data('wp-toggle'); |
| 475 |
// FixIn: 8.8.1.15. |
| 476 |
$table.find( '.wpbc_selectable_body' ).filter(':visible') |
| 477 |
.find('.check-column').find(':checkbox') |
| 478 |
.prop('checked', function() { |
| 479 |
|
| 480 |
if ( $(this).is(':hidden,:disabled') ) { |
| 481 |
return false; |
| 482 |
} |
| 483 |
|
| 484 |
if ( toggle ) { |
| 485 |
return ! $(this).prop( 'checked' ); |
| 486 |
} else if ( controlChecked ) { |
| 487 |
return true; |
| 488 |
} |
| 489 |
|
| 490 |
return false; |
| 491 |
}).trigger( 'change' ); // FixIn: 9.9.0.7. |
| 492 |
|
| 493 |
// FixIn: 8.8.1.15. |
| 494 |
$table.find('.wpbc_selectable_head, .wpbc_selectable_foot').filter(':visible') |
| 495 |
.find('.check-column').find(':checkbox') |
| 496 |
.prop('checked', function() { |
| 497 |
if ( toggle ) { |
| 498 |
return false; |
| 499 |
} else if ( controlChecked ) { |
| 500 |
return true; |
| 501 |
} |
| 502 |
|
| 503 |
return false; |
| 504 |
}); |
| 505 |
}); |
| 506 |
}); |
| 507 |
}( jQuery ) ); |
| 508 |
|
| 509 |
// FixIn: 8.4.7.14. |
| 510 |
function wpbc_are_you_sure_popup(){ |
| 511 |
if ( wpbc_are_you_sure( 'Do you really want to do this ?' ) ) { |
| 512 |
return true; |
| 513 |
} else { |
| 514 |
return false; |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
/** |
| 519 |
* Open or Close Hidden sections |
| 520 |
*/ |
| 521 |
jQuery( document ).ready( function (){ |
| 522 |
jQuery( '.wpbc_container_open_or_closed__link' ).on( 'click', function (){ |
| 523 |
var toggle_el = jQuery( this ).parents( '.wpbc_container_open_or_closed' ); |
| 524 |
if ( toggle_el.length > 0 ){ |
| 525 |
jQuery( toggle_el.get( 0 ) ).toggleClass( 'wpbc_container_closed' ).find( '.wpbc_container_open_or_closed__content' ).toggle(); |
| 526 |
} |
| 527 |
} ); |
| 528 |
} ); |
| 529 |
|