| 1 |
/* |
| 2 |
* Copyright (c) 2022 LatePoint LLC. All rights reserved. |
| 3 |
*/ |
| 4 |
|
| 5 |
// @codekit-prepend "bin/time.js"; |
| 6 |
// @codekit-prepend "bin/lateselect.js"; |
| 7 |
// @codekit-prepend "bin/latecheckbox.js"; |
| 8 |
// @codekit-prepend "bin/actions.js"; |
| 9 |
// @codekit-prepend "bin/notifications.js"; |
| 10 |
// @codekit-prepend "bin/shared.js"; |
| 11 |
// @codekit-prepend "bin/admin/updates.js"; |
| 12 |
// @codekit-prepend "bin/admin/main.js"; |
| 13 |
// @codekit-prepend "bin/admin/_delete-confirm.js"; |
| 14 |
// @codekit-prepend "bin/admin/_agents.js"; |
| 15 |
// @codekit-prepend "bin/admin/_customers.js"; |
| 16 |
// @codekit-prepend "bin/admin/_customers_import.js"; |
| 17 |
// @codekit-prepend "bin/admin/_chart.js"; |
| 18 |
// @codekit-prepend "bin/admin/_calendar.js"; |
| 19 |
// @codekit-prepend "bin/admin/_processes.js"; |
| 20 |
// @codekit-prepend "bin/admin/_steps.js"; |
| 21 |
// @codekit-prepend "bin/admin/_orders.js"; |
| 22 |
// @codekit-prepend "bin/admin/_stripe_connect.js"; |
| 23 |
// @codekit-prepend "bin/admin/_razorpay_connect.js"; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
// DOCUMENT READY |
| 28 |
jQuery(document).ready(function( $ ) { |
| 29 |
|
| 30 |
|
| 31 |
// DASHBOARD |
| 32 |
latepoint_init_calendars(); |
| 33 |
latepoint_init_circles_charts(); |
| 34 |
latepoint_init_donut_charts(); |
| 35 |
latepoint_init_daily_bookings_chart(); |
| 36 |
latepoint_init_element_togglers(); |
| 37 |
latepoint_init_daterangepicker(jQuery('.os-date-range-picker')); |
| 38 |
latepoint_init_monthly_view(); |
| 39 |
latepoint_init_form_blocks(); |
| 40 |
latepoint_init_reminders_form(); |
| 41 |
latepoint_init_coupons_form(); |
| 42 |
latepoint_init_copy_on_click_elements(); |
| 43 |
latepoint_init_side_menu(); |
| 44 |
latepoint_init_color_picker(); |
| 45 |
latepoint_init_clickable_cells(); |
| 46 |
latepoint_init_bookings_bulk(); |
| 47 |
latepoint_init_delete_confirm(); |
| 48 |
latepoint_init_input_masks(); |
| 49 |
latepoint_init_process_forms(); |
| 50 |
latepoint_init_sticky_side_menu(); |
| 51 |
latepoint_init_sortable_columns(); |
| 52 |
latepoint_init_accordions(); |
| 53 |
latepoint_init_default_form_fields_settings(); |
| 54 |
latepoint_init_steps_settings(); |
| 55 |
latepoint_init_booking_form_preview(); |
| 56 |
latepoint_init_sticky_side_nav(); |
| 57 |
latepoint_init_version5_intro(); |
| 58 |
|
| 59 |
jQuery(document).on({ |
| 60 |
mouseenter: function () { |
| 61 |
let $elem = jQuery(this); |
| 62 |
let offset = $elem.offset(); |
| 63 |
jQuery('body > .late-tooltip').remove(); |
| 64 |
let $popup = jQuery('<div/>').addClass('late-tooltip').text($elem.data('late-tooltip')).appendTo(jQuery('body')); |
| 65 |
$popup.css('top', offset.top - 2); |
| 66 |
$popup.css('left', offset.left + $elem.outerWidth() / 2); |
| 67 |
return false; |
| 68 |
}, |
| 69 |
mouseleave: function () { |
| 70 |
jQuery('body > .late-tooltip').remove(); |
| 71 |
} |
| 72 |
}, "[data-late-tooltip]"); |
| 73 |
|
| 74 |
jQuery('body').on('click', '.disabled-items-open-trigger', function(){ |
| 75 |
jQuery(this).closest('.disabled-items-wrapper').toggleClass('is-open'); |
| 76 |
return false; |
| 77 |
}); |
| 78 |
|
| 79 |
jQuery('body').on('click', '.latepoint-side-panel-close', function(){ |
| 80 |
jQuery('.side-sub-panel-wrapper').remove(); |
| 81 |
return false; |
| 82 |
}); |
| 83 |
|
| 84 |
jQuery('#settings_list_of_phone_countries').on('change', function(){ |
| 85 |
if(jQuery(this).val() == latepoint_helper.value_all){ |
| 86 |
jQuery('.select-phone-countries-wrapper').hide(); |
| 87 |
}else{ |
| 88 |
jQuery('.select-phone-countries-wrapper').show(); |
| 89 |
} |
| 90 |
}); |
| 91 |
|
| 92 |
|
| 93 |
jQuery('.os-select-all-toggler').on('change', function(){ |
| 94 |
var $connection_wrappers = jQuery(this).closest('.white-box').find('.os-complex-connections-selector .connection'); |
| 95 |
if(jQuery(this).is(':checked')){ |
| 96 |
latepoint_complex_selector_select($connection_wrappers); |
| 97 |
}else{ |
| 98 |
latepoint_complex_selector_deselect($connection_wrappers); |
| 99 |
} |
| 100 |
return false; |
| 101 |
}); |
| 102 |
|
| 103 |
|
| 104 |
jQuery('.os-main-location-selector').on('change', function(){ |
| 105 |
var route = jQuery(this).data('route'); |
| 106 |
var params = 'id=' + jQuery(this).val(); |
| 107 |
var data = { action: latepoint_helper.route_action, route_name: route, params: params, layout: 'none', return_format: 'json' }; |
| 108 |
jQuery('.latepoint-content-w').addClass('os-loading'); |
| 109 |
jQuery.ajax({ |
| 110 |
type : "post", |
| 111 |
dataType : "json", |
| 112 |
url : latepoint_timestamped_ajaxurl(), |
| 113 |
data : data, |
| 114 |
success: function(data){ |
| 115 |
location.reload(); |
| 116 |
} |
| 117 |
}); |
| 118 |
}); |
| 119 |
|
| 120 |
jQuery('.os-service-durations-w').on('click', '.os-remove-duration', function(){ |
| 121 |
jQuery(this).closest('.duration-box').slideUp(300, function(){ |
| 122 |
jQuery(this).remove(); |
| 123 |
}); |
| 124 |
return false; |
| 125 |
}); |
| 126 |
|
| 127 |
|
| 128 |
jQuery('.menu-color-toggler').on('click', function(){ |
| 129 |
jQuery('.latepoint-side-menu-w').toggleClass('dark'); |
| 130 |
return false; |
| 131 |
}); |
| 132 |
|
| 133 |
|
| 134 |
jQuery('.latepoint-mobile-top-menu-trigger').on('click', function(){ |
| 135 |
jQuery(this).closest('.latepoint-all-wrapper').toggleClass('os-show-mobile-menu'); |
| 136 |
if(jQuery(this).closest('.latepoint-all-wrapper').hasClass('os-show-mobile-menu')){ |
| 137 |
jQuery('.latepoint-side-menu-w ul.side-menu > li.has-children > a').on('click', function(){ |
| 138 |
jQuery(this).closest('li').toggleClass('menu-item-sub-open-mobile'); |
| 139 |
return false; |
| 140 |
}); |
| 141 |
}else{ |
| 142 |
jQuery('.latepoint-side-menu-w ul.side-menu > li.has-children > a').off('click'); |
| 143 |
} |
| 144 |
return false; |
| 145 |
}); |
| 146 |
|
| 147 |
jQuery('.latepoint-mobile-top-search-trigger-cancel').on('click', function(){ |
| 148 |
jQuery(this).closest('.latepoint-all-wrapper').removeClass('os-show-mobile-search'); |
| 149 |
return false; |
| 150 |
}); |
| 151 |
|
| 152 |
jQuery('.latepoint-mobile-top-search-trigger').on('click', function(){ |
| 153 |
jQuery(this).closest('.latepoint-all-wrapper').toggleClass('os-show-mobile-search'); |
| 154 |
if(jQuery(this).closest('.latepoint-all-wrapper').hasClass('os-show-mobile-search')){ |
| 155 |
jQuery('.latepoint-top-search').trigger('focus'); |
| 156 |
} |
| 157 |
return false; |
| 158 |
}); |
| 159 |
|
| 160 |
|
| 161 |
jQuery('.latepoint-top-bar-w').on('click', '.top-user-info-toggler', function(){ |
| 162 |
jQuery('.latepoint-user-info-dropdown').toggleClass('os-visible'); |
| 163 |
return false; |
| 164 |
}); |
| 165 |
|
| 166 |
jQuery('.latepoint-content').on('click', '.mobile-calendar-actions-trigger', function(){ |
| 167 |
jQuery(this).closest('.calendar-mobile-controls').toggleClass('os-show-actions'); |
| 168 |
return false; |
| 169 |
}); |
| 170 |
|
| 171 |
jQuery('.latepoint-content').on('click', '.os-widget-header-actions-trigger', function(){ |
| 172 |
jQuery(this).closest('.os-widget-header').toggleClass('os-show-actions'); |
| 173 |
return false; |
| 174 |
}); |
| 175 |
|
| 176 |
jQuery('.latepoint-content').on('click', '.mobile-table-actions-trigger', function(){ |
| 177 |
jQuery(this).closest('.os-pagination-w').toggleClass('os-show-actions'); |
| 178 |
return false; |
| 179 |
}); |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
jQuery('.download-csv-with-filters').on('click', function(){ |
| 187 |
var filter_params = jQuery(this).closest('.table-with-pagination-w').find('.os-table-filter').serialize(); |
| 188 |
filter_params+= '&download=csv'; |
| 189 |
jQuery(this).attr('href', this.href + '&' + filter_params); |
| 190 |
}); |
| 191 |
|
| 192 |
jQuery('select.pagination-page-select').on('change', function(){ |
| 193 |
latepoint_filter_table(jQuery(this).closest('.table-with-pagination-w').find('table'), jQuery(this).closest('.pagination-page-select-w'), false); |
| 194 |
}); |
| 195 |
|
| 196 |
jQuery('select.os-table-filter').on('change', function(){ |
| 197 |
latepoint_filter_table(jQuery(this).closest('table'), jQuery(this).closest('.os-form-group')); |
| 198 |
}); |
| 199 |
|
| 200 |
jQuery('input.os-table-filter').on('keyup', function(){ |
| 201 |
latepoint_filter_table(jQuery(this).closest('table'), jQuery(this).closest('.os-form-group')); |
| 202 |
}); |
| 203 |
|
| 204 |
|
| 205 |
jQuery('.customize-connection-btn').on('click', function(){ |
| 206 |
jQuery(this).closest('.connection').toggleClass('show-customize-box'); |
| 207 |
return false; |
| 208 |
}); |
| 209 |
|
| 210 |
jQuery('.connection-children-list').on('click', 'li', function(){ |
| 211 |
if(jQuery(this).hasClass('active')){ |
| 212 |
jQuery(this).removeClass('active'); |
| 213 |
jQuery(this).find('input.connection-child-is-connected').val('no'); |
| 214 |
}else{ |
| 215 |
jQuery(this).addClass('active'); |
| 216 |
jQuery(this).find('input.connection-child-is-connected').val('yes'); |
| 217 |
} |
| 218 |
latepoint_count_active_connections(jQuery(this).closest('.connection')); |
| 219 |
return false; |
| 220 |
}); |
| 221 |
|
| 222 |
jQuery('.display-toggler-control').on('change', function(){ |
| 223 |
let group = jQuery(this).data('toggler-group'); |
| 224 |
let key = jQuery(this).val(); |
| 225 |
jQuery('.display-toggler-target[data-toggler-group="' + group + '"]').hide(); |
| 226 |
jQuery('.display-toggler-target[data-toggler-group="' + group + '"][data-toggler-key="'+ key +'"]').show(); |
| 227 |
return false; |
| 228 |
}); |
| 229 |
|
| 230 |
jQuery('.add-item-category-trigger').on('click', function(){ |
| 231 |
jQuery('.add-item-category-box').toggle(); |
| 232 |
jQuery('.os-new-item-category-form-w').toggle(); |
| 233 |
return false; |
| 234 |
}); |
| 235 |
|
| 236 |
jQuery('.latepoint-top-search').on('keyup', function(event){ |
| 237 |
var $wrapper = jQuery(this).closest('.latepoint-top-search-w'); |
| 238 |
$wrapper.addClass('os-loading'); |
| 239 |
var query = jQuery(this).val(); |
| 240 |
if(event.keyCode == 27){ |
| 241 |
$wrapper.removeClass('typing'); |
| 242 |
jQuery('.latepoint-top-search-results-w').html(''); |
| 243 |
jQuery(this).val(''); |
| 244 |
$wrapper.removeClass('os-loading'); |
| 245 |
return; |
| 246 |
} |
| 247 |
if(query == ''){ |
| 248 |
$wrapper.removeClass('typing'); |
| 249 |
jQuery('.latepoint-top-search-results-w').html(''); |
| 250 |
$wrapper.removeClass('os-loading'); |
| 251 |
return; |
| 252 |
} |
| 253 |
var route = jQuery(this).data('route'); |
| 254 |
var params = 'query=' + query; |
| 255 |
var data = { action: latepoint_helper.route_action, route_name: route, params: params, layout: 'none', return_format: 'json' }; |
| 256 |
$wrapper.addClass('typing'); |
| 257 |
jQuery.ajax({ |
| 258 |
type : "post", |
| 259 |
dataType : "json", |
| 260 |
url : latepoint_timestamped_ajaxurl(), |
| 261 |
data : data, |
| 262 |
success: function(data){ |
| 263 |
if(!$wrapper.hasClass('typing')) return; |
| 264 |
$wrapper.removeClass('os-loading'); |
| 265 |
if(data.status === "success"){ |
| 266 |
jQuery('.latepoint-top-search-results-w').html(data.message); |
| 267 |
}else{ |
| 268 |
// console.log(data.message); |
| 269 |
} |
| 270 |
} |
| 271 |
}); |
| 272 |
}); |
| 273 |
|
| 274 |
|
| 275 |
jQuery('.appointment-status-selector').on('click', function(e){ |
| 276 |
e.stopPropagation(); |
| 277 |
}); |
| 278 |
|
| 279 |
jQuery('.latepoint-show-license-details').on('click', function(e){ |
| 280 |
jQuery(this).closest('.active-license-info').find('.license-info-w').slideToggle(200); |
| 281 |
return false; |
| 282 |
}); |
| 283 |
|
| 284 |
jQuery('.aba-button-w').on('click', function(e){ |
| 285 |
e.stopPropagation(); |
| 286 |
var confirm_message = (jQuery(this).hasClass('aba-approve')) ? latepoint_helper.approve_confirm : latepoint_helper.reject_confirm; |
| 287 |
if(confirm(confirm_message)){ |
| 288 |
var $box = jQuery(this).closest('.appointment-box-large'); |
| 289 |
$box.find('.appointment-status-selector select').val(jQuery(this).data('status')).trigger('change'); |
| 290 |
} |
| 291 |
return false; |
| 292 |
}); |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
jQuery('.appointment-status-selector select').on('change', function(e){ |
| 297 |
var $wrapper = jQuery(this).closest('.appointment-status-selector'); |
| 298 |
var route = $wrapper.data('route'); |
| 299 |
var nonce = $wrapper.data('wp-nonce'); |
| 300 |
var booking_id = $wrapper.data('booking-id'); |
| 301 |
var status = jQuery(this).val(); |
| 302 |
jQuery(this).closest('.appointment-box-large').attr('class', 'appointment-box-large status-' + status); |
| 303 |
var params = 'id=' + booking_id + '&status=' + status + '&_wpnonce=' + nonce; |
| 304 |
var data = { action: latepoint_helper.route_action, route_name: route, params: params, layout: 'none', return_format: 'json' }; |
| 305 |
jQuery.ajax({ |
| 306 |
type : "post", |
| 307 |
dataType : "json", |
| 308 |
url : latepoint_timestamped_ajaxurl(), |
| 309 |
data : data, |
| 310 |
success: function(data){ |
| 311 |
if(data.status === "success"){ |
| 312 |
latepoint_add_notification(data.message); |
| 313 |
}else{ |
| 314 |
latepoint_add_notification(data.message, 'error'); |
| 315 |
// console.log(data.message); |
| 316 |
} |
| 317 |
} |
| 318 |
}); |
| 319 |
}); |
| 320 |
|
| 321 |
jQuery('body').on('click', '.open-template-variables-panel', function(){ |
| 322 |
jQuery('.latepoint-template-variables').toggleClass('is-visible'); |
| 323 |
return false; |
| 324 |
}); |
| 325 |
|
| 326 |
jQuery('body').on('click', '.close-template-variables-panel', function(){ |
| 327 |
jQuery('.latepoint-template-variables').removeClass('is-visible'); |
| 328 |
return false; |
| 329 |
}); |
| 330 |
|
| 331 |
jQuery('body').on('click', '.open-layout-template-variables-panel', function(){ |
| 332 |
jQuery('.latepoint-layout-template-variables').toggleClass('is-visible'); |
| 333 |
return false; |
| 334 |
}); |
| 335 |
|
| 336 |
jQuery('body').on('click', '.close-layout-template-variables-panel', function(){ |
| 337 |
jQuery('.latepoint-layout-template-variables').removeClass('is-visible'); |
| 338 |
return false; |
| 339 |
}); |
| 340 |
|
| 341 |
jQuery('body').on('click', '.os-notifications .os-notification-close', function(){ |
| 342 |
jQuery(this).closest('.item').remove(); |
| 343 |
return false; |
| 344 |
}); |
| 345 |
|
| 346 |
|
| 347 |
jQuery('body').on('keyup', '.os-form-group .os-form-control', function(){ |
| 348 |
if(jQuery(this).val()){ |
| 349 |
jQuery(this).closest('.os-form-group').addClass('has-value'); |
| 350 |
}else{ |
| 351 |
jQuery(this).closest('.os-form-group').removeClass('has-value'); |
| 352 |
} |
| 353 |
}); |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
jQuery('.os-wizard-setup-w, .latepoint-settings-w, .custom-schedule-wrapper').on('click', '.ws-head', function(){ |
| 358 |
var $schedule_wrapper = jQuery(this).closest('.weekday-schedule-w'); |
| 359 |
$schedule_wrapper.toggleClass('is-editing').removeClass('day-off'); |
| 360 |
$schedule_wrapper.find('.os-toggler').removeClass('off'); |
| 361 |
$schedule_wrapper.find('input.is-active').val(1); |
| 362 |
}); |
| 363 |
|
| 364 |
|
| 365 |
jQuery('body.latepoint').on('click', '.wizard-add-edit-item-trigger', function(e){ |
| 366 |
jQuery(this).addClass('os-loading'); |
| 367 |
var add_item_route_name = jQuery(this).data('route'); |
| 368 |
var item_info = { }; |
| 369 |
if(jQuery(this).data('id')){ |
| 370 |
item_info.id = jQuery(this).data('id'); |
| 371 |
} |
| 372 |
var data = { action: latepoint_helper.route_action, route_name: add_item_route_name, params: item_info, layout: 'none', return_format: 'json' }; |
| 373 |
jQuery.ajax({ |
| 374 |
type : "post", |
| 375 |
dataType : "json", |
| 376 |
url : latepoint_timestamped_ajaxurl(), |
| 377 |
data : data, |
| 378 |
success: function(data){ |
| 379 |
jQuery('.wizard-add-edit-item-trigger.os-loading').removeClass('os-loading'); |
| 380 |
if(data.status === "success"){ |
| 381 |
jQuery('.os-wizard-step-content-i').html(data.message); |
| 382 |
jQuery('.os-wizard-setup-w').addClass('is-sub-editing'); |
| 383 |
jQuery('.os-wizard-footer').hide(); |
| 384 |
latepoint_init_wizard_content(); |
| 385 |
}else{ |
| 386 |
// console.log(data.message); |
| 387 |
} |
| 388 |
} |
| 389 |
}); |
| 390 |
}); |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
jQuery('body.latepoint').on('click', '.os-wizard-trigger-next-btn', function(){ |
| 396 |
var $next_btn = jQuery(this); |
| 397 |
$next_btn.addClass('os-loading'); |
| 398 |
var current_step_code = jQuery('#wizard_current_step_code').val(); |
| 399 |
var params = 'current_step_code='+current_step_code; |
| 400 |
|
| 401 |
// work periods step |
| 402 |
if(jQuery('.os-wizard-setup-w form.weekday-schedules-w').length){ |
| 403 |
params+= '&'+ jQuery('.os-wizard-setup-w form.weekday-schedules-w .weekday-schedule-w:not(.day-off) input').serialize(); |
| 404 |
} |
| 405 |
// agent/notifications step |
| 406 |
if(jQuery('.os-wizard-default-agent-form').length){ |
| 407 |
params+= '&'+ jQuery('.os-wizard-default-agent-form input').serialize(); |
| 408 |
|
| 409 |
var $form = $('.os-wizard-default-agent-form'); |
| 410 |
var form_data = new FormData($form[0]); |
| 411 |
form_data.set('current_step_code', current_step_code); |
| 412 |
|
| 413 |
if (('lp_intlTelInputGlobals' in window) && ('lp_intlTelInputUtils' in window)) { |
| 414 |
// Get e164 formatted number from phone fields when form is submitted |
| 415 |
$form.find('input.os-mask-phone').each(function () { |
| 416 |
let telInstance = window.lp_intlTelInputGlobals.getInstance(this); |
| 417 |
if(telInstance){ |
| 418 |
const phoneInputName = this.getAttribute('name'); |
| 419 |
const phoneInputValue = window.lp_intlTelInputGlobals.getInstance(this).getNumber(window.lp_intlTelInputUtils.numberFormat.E164); |
| 420 |
form_data.set(phoneInputName, phoneInputValue); |
| 421 |
} |
| 422 |
}); |
| 423 |
} |
| 424 |
params = latepoint_formdata_to_url_encoded_string(form_data); |
| 425 |
} |
| 426 |
// personal info step |
| 427 |
if(jQuery('.os-wizard-personal-info-form').length){ |
| 428 |
params+= '&'+ jQuery('.os-wizard-personal-info-form input').serialize(); |
| 429 |
} |
| 430 |
|
| 431 |
params+= '&_wpnonce='+encodeURIComponent(jQuery('.os-wizard-footer input[name="_wpnonce"]').val()); |
| 432 |
|
| 433 |
var data = { |
| 434 |
action: latepoint_helper.route_action, |
| 435 |
route_name: jQuery(this).data('route-name'), |
| 436 |
params: params, |
| 437 |
layout: 'none', |
| 438 |
return_format: 'json'}; |
| 439 |
jQuery.ajax({ |
| 440 |
type : "post", |
| 441 |
dataType : "json", |
| 442 |
url : latepoint_timestamped_ajaxurl(), |
| 443 |
data : data, |
| 444 |
success: function(data){ |
| 445 |
$next_btn.removeClass('os-loading'); |
| 446 |
if(data.status === "success"){ |
| 447 |
jQuery('#wizard_current_step_code').val(data.step_code); |
| 448 |
jQuery('.os-wizard-setup-w').attr('class', 'os-wizard-setup-w step-' + data.step_code); |
| 449 |
jQuery('.os-wizard-step-content').html(data.message); |
| 450 |
latepoint_init_wizard_content(); |
| 451 |
if(data.show_prev_btn){ |
| 452 |
jQuery('.os-wizard-prev-btn').show(); |
| 453 |
}else{ |
| 454 |
jQuery('.os-wizard-prev-btn').hide(); |
| 455 |
} |
| 456 |
if(data.show_next_btn){ |
| 457 |
jQuery('.os-wizard-next-btn').show(); |
| 458 |
}else{ |
| 459 |
jQuery('.os-wizard-next-btn').hide(); |
| 460 |
} |
| 461 |
if(!data.show_next_btn && !data.show_prev_btn){ |
| 462 |
jQuery('.os-wizard-footer').hide(); |
| 463 |
}else{ |
| 464 |
jQuery('.os-wizard-footer').show(); |
| 465 |
} |
| 466 |
} |
| 467 |
} |
| 468 |
}); |
| 469 |
return false; |
| 470 |
}); |
| 471 |
|
| 472 |
// WIZARD PREV BUTTON CLICK LOGIC |
| 473 |
jQuery('body.latepoint').on('click', '.os-wizard-trigger-prev-btn', function(){ |
| 474 |
var $prev_btn = jQuery(this); |
| 475 |
$prev_btn.addClass('os-loading'); |
| 476 |
var current_step_code = jQuery('#wizard_current_step_code').val(); |
| 477 |
var params = 'current_step_code='+current_step_code; |
| 478 |
params+= '&_wpnonce='+encodeURIComponent(jQuery('.os-wizard-footer input[name="_wpnonce"]').val()); |
| 479 |
var data = { action: latepoint_helper.route_action, route_name: jQuery(this).data('route-name'), params: params, layout: 'none', return_format: 'json'}; |
| 480 |
jQuery.ajax({ |
| 481 |
type : "post", |
| 482 |
dataType : "json", |
| 483 |
url : latepoint_timestamped_ajaxurl(), |
| 484 |
data : data, |
| 485 |
success: function(data){ |
| 486 |
$prev_btn.removeClass('os-loading'); |
| 487 |
if(data.status === "success"){ |
| 488 |
jQuery('#wizard_current_step_code').val(data.step_code); |
| 489 |
jQuery('.os-wizard-setup-w').attr('class', 'os-wizard-setup-w step-' + data.step_code); |
| 490 |
jQuery('.os-wizard-step-content').html(data.message); |
| 491 |
latepoint_init_wizard_content(); |
| 492 |
if(data.show_prev_btn){ |
| 493 |
jQuery('.os-wizard-prev-btn').show(); |
| 494 |
}else{ |
| 495 |
jQuery('.os-wizard-prev-btn').hide(); |
| 496 |
} |
| 497 |
if(data.show_next_btn){ |
| 498 |
jQuery('.os-wizard-next-btn').show(); |
| 499 |
}else{ |
| 500 |
jQuery('.os-wizard-next-btn').hide(); |
| 501 |
} |
| 502 |
if(!data.show_next_btn && !data.show_prev_btn){ |
| 503 |
jQuery('.os-wizard-footer').hide(); |
| 504 |
}else{ |
| 505 |
jQuery('.os-wizard-footer').show(); |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
}); |
| 510 |
return false; |
| 511 |
}); |
| 512 |
|
| 513 |
// WIZARD SKIP SETUP BUTTON CLICK LOGIC |
| 514 |
jQuery('body.latepoint').on('click', '.os-wizard-skip-btn', function(e){ |
| 515 |
e.preventDefault(); |
| 516 |
var current_step_code = jQuery('#wizard_current_step_code').val(); |
| 517 |
var params = 'current_step_code=' + current_step_code; |
| 518 |
params += '&_wpnonce=' + encodeURIComponent(jQuery('.os-wizard-footer input[name="_wpnonce"]').val()); |
| 519 |
var data = { |
| 520 |
action: latepoint_helper.route_action, |
| 521 |
route_name: jQuery(this).data('route-name'), |
| 522 |
params: params, |
| 523 |
layout: 'none', |
| 524 |
return_format: 'json' |
| 525 |
}; |
| 526 |
jQuery.ajax({ |
| 527 |
type: "post", |
| 528 |
dataType: "json", |
| 529 |
url: latepoint_timestamped_ajaxurl(), |
| 530 |
data: data, |
| 531 |
success: function(data){ |
| 532 |
if(data.status === "success" && data.redirect){ |
| 533 |
window.location.href = data.redirect; |
| 534 |
} |
| 535 |
} |
| 536 |
}); |
| 537 |
return false; |
| 538 |
}); |
| 539 |
|
| 540 |
jQuery('.latepoint-content-w').on('change', '.os-widget .os-trigger-reload-widget', function(){ |
| 541 |
latepoint_reload_widget(jQuery(this).closest('.os-widget')); |
| 542 |
}); |
| 543 |
|
| 544 |
jQuery('.latepoint-content-w').on('click', '.os-widget .timeline-type-toggle .timeline-type-option', function(){ |
| 545 |
jQuery(this).closest('.timeline-type-toggle').find('.timeline-type-option.active').removeClass('active'); |
| 546 |
jQuery(this).addClass('active'); |
| 547 |
jQuery('.timeline-and-availability-contents').removeClass('shows-appointments shows-availability').addClass('shows-' + jQuery(this).data('value')); |
| 548 |
jQuery('#' + jQuery(this).closest('.timeline-type-toggle').data('value-holder-id')).val(jQuery(this).data('value')); |
| 549 |
}); |
| 550 |
|
| 551 |
|
| 552 |
dragula([].slice.apply(document.querySelectorAll('.os-categories-ordering-w .os-category-children')), { |
| 553 |
moves: function (el, container, handle) { |
| 554 |
return (handle.classList.contains('os-category-drag') || handle.classList.contains('os-category-item-drag')); |
| 555 |
}, |
| 556 |
}).on('drop', function(el){ |
| 557 |
var $categories_wrapper = jQuery('.os-categories-ordering-w'); |
| 558 |
var category_datas = []; |
| 559 |
var item_datas = []; |
| 560 |
|
| 561 |
$categories_wrapper.find('.os-category-parent-w').each(function(index){ |
| 562 |
var order_number = jQuery(this).index() + 1; |
| 563 |
var parent_id = jQuery(this).parent().closest('.os-category-parent-w').data('id') || 0; |
| 564 |
category_datas.push({id: jQuery(this).data('id'), order_number: order_number, parent_id: parent_id}); |
| 565 |
}); |
| 566 |
$categories_wrapper.find('.item-in-category-w').each(function(index){ |
| 567 |
var item_order_number = jQuery(this).index() + 1; |
| 568 |
var category_id = jQuery(this).closest('.os-category-parent-w').data('id') || 0; |
| 569 |
item_datas.push({id: jQuery(this).data('id'), order_number: item_order_number, category_id: category_id}); |
| 570 |
}); |
| 571 |
latepoint_recalculate_items_count_in_category(); |
| 572 |
var data = { action: latepoint_helper.route_action, route_name: $categories_wrapper.data('category-order-update-route'), params: {category_datas: category_datas, item_datas: item_datas}, return_format: 'json' } |
| 573 |
$categories_wrapper.addClass('os-loading'); |
| 574 |
jQuery.ajax({ |
| 575 |
type : "post", |
| 576 |
dataType : "json", |
| 577 |
url : latepoint_timestamped_ajaxurl(), |
| 578 |
data : data, |
| 579 |
success: function(response){ |
| 580 |
$categories_wrapper.removeClass('os-loading'); |
| 581 |
if(response.status === "success"){ |
| 582 |
// latepoint_add_notification(response.message); |
| 583 |
}else{ |
| 584 |
alert(response.message); |
| 585 |
} |
| 586 |
} |
| 587 |
}); |
| 588 |
}); |
| 589 |
|
| 590 |
|
| 591 |
// Universal re-ordering dragging for form blocks |
| 592 |
dragula([jQuery('.os-draggable-form-blocks')[0]], { |
| 593 |
moves: function (el, container, handle) { |
| 594 |
return handle.classList.contains('os-form-block-drag'); |
| 595 |
}, |
| 596 |
}).on('drop', function(el){ |
| 597 |
var blocks_order_data = {}; |
| 598 |
var $draggable_form_blocks_wrapper = jQuery('.os-draggable-form-blocks'); |
| 599 |
$draggable_form_blocks_wrapper.find('.os-form-block').each(function(index){ |
| 600 |
var new_order_number = jQuery(this).index() + 1; |
| 601 |
var $block_model_id = jQuery(this).find('.os-form-block-id'); |
| 602 |
if($block_model_id.length && $block_model_id.val()) blocks_order_data[$block_model_id.val()] = new_order_number; |
| 603 |
}); |
| 604 |
var data = { action: latepoint_helper.route_action, |
| 605 |
route_name: $draggable_form_blocks_wrapper.data('order-update-route'), |
| 606 |
params: {ordered_fields: blocks_order_data, |
| 607 |
fields_for: $draggable_form_blocks_wrapper.data('fields-for'), |
| 608 |
_wpnonce: $draggable_form_blocks_wrapper.data('order-update-nonce')}, |
| 609 |
return_format: 'json' } |
| 610 |
$draggable_form_blocks_wrapper.addClass('os-loading'); |
| 611 |
jQuery.ajax({ |
| 612 |
type : "post", |
| 613 |
dataType : "json", |
| 614 |
url : latepoint_timestamped_ajaxurl(), |
| 615 |
data : data, |
| 616 |
success: function(response){ |
| 617 |
$draggable_form_blocks_wrapper.removeClass('os-loading'); |
| 618 |
} |
| 619 |
}); |
| 620 |
}); |
| 621 |
|
| 622 |
|
| 623 |
jQuery('body.latepoint-admin').on('click', '.os-category-edit-btn, .os-category-edit-cancel-btn, .os-category-w .os-category-name', function(){ |
| 624 |
jQuery(this).closest('.os-category-w').toggleClass('editing'); |
| 625 |
return false; |
| 626 |
}); |
| 627 |
|
| 628 |
jQuery('body.latepoint-admin').on('click', '.step-edit-btn, .step-edit-cancel-btn, .step-w .step-head', function(){ |
| 629 |
jQuery(this).closest('.step-w').toggleClass('editing'); |
| 630 |
return false; |
| 631 |
}); |
| 632 |
|
| 633 |
jQuery('body.latepoint-admin').on('click', '.agent-info-change-agent-btn', function(){ |
| 634 |
jQuery(this).closest('.agent-info-w').removeClass('selected').addClass('selecting'); |
| 635 |
return false; |
| 636 |
}); |
| 637 |
|
| 638 |
jQuery('body.latepoint-admin').on('click', '.agent-info-change-agent-btn', function(){ |
| 639 |
jQuery(this).closest('.agent-info-w').removeClass('selected').addClass('selecting'); |
| 640 |
return false; |
| 641 |
}); |
| 642 |
|
| 643 |
|
| 644 |
jQuery('body.latepoint-admin').on('click', '.customer-info-create-btn', function(){ |
| 645 |
jQuery(this).closest('.customer-info-w').removeClass('selecting').addClass('selected'); |
| 646 |
return false; |
| 647 |
}); |
| 648 |
|
| 649 |
jQuery('body.latepoint-admin').on('click', '.customer-info-load-btn', function(){ |
| 650 |
jQuery(this).closest('.customer-info-w').removeClass('selected').addClass('selecting').find('.customers-selector-search-input').trigger('focus'); |
| 651 |
return false; |
| 652 |
}); |
| 653 |
|
| 654 |
jQuery('body.latepoint-admin').on('click', '.customers-selector-cancel', function(){ |
| 655 |
jQuery(this).closest('.customer-info-w').removeClass('selecting').addClass('selected '); |
| 656 |
jQuery('.customers-options-list .customer-option').show(); |
| 657 |
jQuery('.customers-selector-search-input').val(''); |
| 658 |
return false; |
| 659 |
}); |
| 660 |
|
| 661 |
// CUSTOMER SELECTOR |
| 662 |
|
| 663 |
// SERVICES SELECTOR |
| 664 |
jQuery('body.latepoint-admin').on('click', '.service-option-selected', function(){ |
| 665 |
var $select = jQuery(this).closest('.os-services-select-field-w'); |
| 666 |
if($select.hasClass('active')){ |
| 667 |
$select.removeClass('active'); |
| 668 |
}else{ |
| 669 |
$select.addClass('active').find('input').trigger('focus'); |
| 670 |
} |
| 671 |
return false; |
| 672 |
}); |
| 673 |
|
| 674 |
|
| 675 |
jQuery('body.latepoint-admin').on('keyup', '.service-options-filter-input', function(){ |
| 676 |
var $list = jQuery(this).closest('.services-options-list'); |
| 677 |
var text = jQuery(this).val().toLowerCase(); |
| 678 |
$list.find('.service-option').hide(); |
| 679 |
|
| 680 |
// Search |
| 681 |
$list.find('.service-option').each(function(){ |
| 682 |
|
| 683 |
if(jQuery(this).text().toLowerCase().indexOf(""+text+"") != -1 ){ |
| 684 |
jQuery(this).show(); |
| 685 |
} |
| 686 |
}); |
| 687 |
return false; |
| 688 |
}); |
| 689 |
|
| 690 |
|
| 691 |
jQuery('.calendar-week-agent-w').on('click', '.calendar-load-target-date', function(event){ |
| 692 |
jQuery(this).addClass('os-loading'); |
| 693 |
latepoint_reload_week_view_calendar(jQuery(this).data('target-date')); |
| 694 |
return false; |
| 695 |
}); |
| 696 |
|
| 697 |
jQuery('.calendar-week-agent-w').on('change', '.cc-availability-toggler #overlay_service_availability', function(event){ |
| 698 |
if(jQuery(this).val() == 'on'){ |
| 699 |
jQuery('.calendar-week-agent-w .cc-service-selector').show(); |
| 700 |
}else{ |
| 701 |
jQuery('.calendar-week-agent-w .cc-service-selector').hide(); |
| 702 |
} |
| 703 |
latepoint_reload_week_view_calendar(); |
| 704 |
}); |
| 705 |
|
| 706 |
|
| 707 |
jQuery('.calendar-week-agent-w').on('change', '.trigger-weekly-calendar-reload', function(event){ |
| 708 |
latepoint_reload_week_view_calendar(); |
| 709 |
return false; |
| 710 |
}); |
| 711 |
|
| 712 |
jQuery('.latepoint-admin').on('click', '.os-complex-connections-selector .selector-trigger', function(e){ |
| 713 |
var $connection_wrapper = jQuery(this).closest('.connection'); |
| 714 |
if($connection_wrapper.hasClass('active')){ |
| 715 |
latepoint_complex_selector_deselect($connection_wrapper); |
| 716 |
jQuery(this).closest('.white-box').find('.os-select-all-toggler').prop('checked', false); |
| 717 |
}else{ |
| 718 |
latepoint_complex_selector_select($connection_wrapper); |
| 719 |
} |
| 720 |
return false; |
| 721 |
}); |
| 722 |
|
| 723 |
jQuery('.latepoint-admin').on('click', '.os-complex-connections-selector .item-quantity-selector', function(e){ |
| 724 |
let val = parseInt(jQuery(this).closest('.item-quantity-selector-w').find('.item-quantity-selector-input').val()); |
| 725 |
if(jQuery(this).data('sign') == 'plus'){ |
| 726 |
val = val + 1; |
| 727 |
}else{ |
| 728 |
val = val - 1; |
| 729 |
} |
| 730 |
val = (val > 0) ? val : 0; |
| 731 |
jQuery(this).closest('.item-quantity-selector-w').find('.item-quantity-selector-input').val(val).trigger('change'); |
| 732 |
return false; |
| 733 |
}); |
| 734 |
|
| 735 |
jQuery('.latepoint-admin').on('change', '.os-complex-connections-selector .item-quantity-selector-input', function(e){ |
| 736 |
let $this = jQuery(this); |
| 737 |
let $connection_wrapper = jQuery(this).closest('.connection'); |
| 738 |
if($this.val() > 0){ |
| 739 |
latepoint_complex_selector_select($connection_wrapper, $this.val()); |
| 740 |
}else{ |
| 741 |
latepoint_complex_selector_deselect($connection_wrapper); |
| 742 |
} |
| 743 |
return false; |
| 744 |
}); |
| 745 |
|
| 746 |
jQuery('.latepoint-admin').on('click', '.os-agents-selector .agent', function(){ |
| 747 |
if(jQuery(this).hasClass('active')){ |
| 748 |
jQuery(this).removeClass('active'); |
| 749 |
jQuery(this).find('.connection-child-is-connected').val('no'); |
| 750 |
}else{ |
| 751 |
jQuery(this).addClass('active'); |
| 752 |
jQuery(this).find('.connection-child-is-connected').val('yes'); |
| 753 |
} |
| 754 |
return false; |
| 755 |
}); |
| 756 |
|
| 757 |
jQuery('.latepoint-admin').on('click', '.os-services-selector .service', function(){ |
| 758 |
if(jQuery(this).hasClass('active')){ |
| 759 |
jQuery(this).removeClass('active'); |
| 760 |
jQuery(this).find('.connection-child-is-connected').val('no'); |
| 761 |
}else{ |
| 762 |
jQuery(this).addClass('active'); |
| 763 |
jQuery(this).find('.connection-child-is-connected').val('yes'); |
| 764 |
} |
| 765 |
return false; |
| 766 |
}); |
| 767 |
|
| 768 |
jQuery('.latepoint-admin').on( 'click', '.os-form-toggler-group', function( event ){ |
| 769 |
if (jQuery(event.target).closest('a').length) { |
| 770 |
return true; |
| 771 |
} |
| 772 |
jQuery(this).find('.os-toggler').trigger('click'); |
| 773 |
return false; |
| 774 |
}); |
| 775 |
|
| 776 |
jQuery('.latepoint-admin').on( 'click', '.os-toggler', function( event ){ |
| 777 |
let $toggler = jQuery(this); |
| 778 |
if($toggler.data('confirm')){ |
| 779 |
if(!confirm($toggler.data('confirm'))) return false; |
| 780 |
} |
| 781 |
if($toggler.hasClass('on')){ |
| 782 |
$toggler.removeClass('on').addClass('off'); |
| 783 |
}else{ |
| 784 |
$toggler.removeClass('off').addClass('on'); |
| 785 |
} |
| 786 |
if($toggler.data('for')){ |
| 787 |
if($toggler.hasClass('os-toggler-radio')){ |
| 788 |
// radio |
| 789 |
// uncheck all radio buttons with the same name |
| 790 |
let $radio = jQuery('#' + $toggler.data('for')); |
| 791 |
jQuery('input[type="radio"][name="'+ $radio.prop('name') + '"]:checked').each(function(index){ |
| 792 |
let toggle_content_id = jQuery(this).prop('checked', false).closest('.os-toggler-w').find('.os-toggler.on').removeClass('on').addClass('off').data('controlled-toggle-id'); |
| 793 |
jQuery('#'+ toggle_content_id).hide(); |
| 794 |
}); |
| 795 |
$radio.prop('checked', !$toggler.hasClass('off')); |
| 796 |
}else{ |
| 797 |
var $hiddenInput = jQuery('input[type="hidden"]#' + $toggler.data('for')); |
| 798 |
if($hiddenInput.length){ |
| 799 |
// hidden input |
| 800 |
if($toggler.data('is-string-value')){ |
| 801 |
$hiddenInput.val($toggler.hasClass('off') ? 'off' : 'on').trigger('change'); |
| 802 |
}else{ |
| 803 |
$hiddenInput.val($toggler.hasClass('off') ? 0 : 1).trigger('change'); |
| 804 |
} |
| 805 |
|
| 806 |
if($toggler.data('os-instant-update')){ |
| 807 |
let data = new FormData(); |
| 808 |
|
| 809 |
let params = $hiddenInput.serialize(); |
| 810 |
if($toggler.data('nonce')) params+= '&_wpnonce='+$toggler.data('nonce'); |
| 811 |
data.append('params', params); |
| 812 |
data.append('action', latepoint_helper.route_action); |
| 813 |
data.append('route_name', $toggler.data('os-instant-update')); |
| 814 |
data.append('return_format', 'json'); |
| 815 |
|
| 816 |
jQuery.ajax({ |
| 817 |
type: "post", |
| 818 |
dataType: "json", |
| 819 |
processData: false, |
| 820 |
contentType: false, |
| 821 |
url: latepoint_timestamped_ajaxurl(), |
| 822 |
data: data, |
| 823 |
success: function (response) { |
| 824 |
|
| 825 |
} |
| 826 |
}); |
| 827 |
} |
| 828 |
}else{ |
| 829 |
// checkbox |
| 830 |
jQuery('#' + $toggler.data('for')).prop('checked', !$toggler.hasClass('off')); |
| 831 |
} |
| 832 |
} |
| 833 |
} |
| 834 |
if($toggler.data('controlled-toggle-id')){ |
| 835 |
if($toggler.hasClass('off')){ |
| 836 |
jQuery('#' + $toggler.data('controlled-toggle-id')).hide(); |
| 837 |
}else{ |
| 838 |
jQuery('#' + $toggler.data('controlled-toggle-id')).show(); |
| 839 |
} |
| 840 |
} |
| 841 |
if($toggler.data('negative-controlled-toggle-id')){ |
| 842 |
if($toggler.hasClass('off')){ |
| 843 |
jQuery('#' + $toggler.data('negative-controlled-toggle-id')).show(); |
| 844 |
}else{ |
| 845 |
jQuery('#' + $toggler.data('negative-controlled-toggle-id')).hide(); |
| 846 |
} |
| 847 |
} |
| 848 |
$toggler.trigger('ostoggler:toggle'); |
| 849 |
return false; |
| 850 |
}); |
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
// UPLOAD/REMOVE IMAGE LINK LOGIC |
| 855 |
jQuery('.latepoint-admin').on( 'click', '.os-image-selector-trigger', function( event ){ |
| 856 |
var frame; |
| 857 |
|
| 858 |
event.preventDefault(); |
| 859 |
|
| 860 |
var $image_uploader_trigger = jQuery(this); |
| 861 |
var $image_selector_w = jQuery(this).closest('.os-image-selector-w'); |
| 862 |
var $image_container = $image_selector_w.find('.os-image-container'); |
| 863 |
var $image_id_holder = $image_selector_w.find('.os-image-id-holder'); |
| 864 |
|
| 865 |
let is_avatar = $image_selector_w.hasClass('is-avatar'); |
| 866 |
|
| 867 |
var image_exists = is_avatar ? $image_container.find('.image-self').length : $image_container.find('img').length; |
| 868 |
|
| 869 |
if(image_exists){ |
| 870 |
$image_id_holder.val(''); |
| 871 |
$image_selector_w.removeClass('has-image'); |
| 872 |
$image_container.html(''); |
| 873 |
$image_uploader_trigger.find('.os-text-holder').text($image_uploader_trigger.data('label-set-str')); |
| 874 |
}else{ |
| 875 |
// If the media frame already exists, reopen it. |
| 876 |
if ( frame ) { |
| 877 |
frame.open(); |
| 878 |
return false; |
| 879 |
} |
| 880 |
|
| 881 |
// Create a new media frame |
| 882 |
frame = wp.media({ |
| 883 |
title: 'Select or Upload Media', |
| 884 |
button: { text: 'Use this media' }, |
| 885 |
multiple: false |
| 886 |
}); |
| 887 |
|
| 888 |
frame.on( 'select', function() { |
| 889 |
var attachment = frame.state().get('selection').first().toJSON(); |
| 890 |
if(is_avatar){ |
| 891 |
$image_container.html( '<div class="image-self" style="background-image: url('+attachment.url+')"></div>' ); |
| 892 |
}else{ |
| 893 |
$image_container.html( '<img src="'+attachment.url+'" alt=""/>' ); |
| 894 |
} |
| 895 |
$image_id_holder.val( attachment.id ); |
| 896 |
$image_selector_w.addClass('has-image'); |
| 897 |
$image_uploader_trigger.find('.os-text-holder').text($image_uploader_trigger.data('label-remove-str')); |
| 898 |
}); |
| 899 |
|
| 900 |
frame.open(); |
| 901 |
} |
| 902 |
|
| 903 |
return false; |
| 904 |
}); |
| 905 |
|
| 906 |
|
| 907 |
jQuery('.latepoint-admin').on('click', '.os-multiple-files-uploader a', function(event) { |
| 908 |
event.stopPropagation(); |
| 909 |
}); |
| 910 |
|
| 911 |
jQuery('.latepoint-admin').on('click', '.os-multiple-files-uploader', function(event) { |
| 912 |
var frame; |
| 913 |
event.preventDefault(); |
| 914 |
|
| 915 |
var $uploader_trigger = jQuery(this); |
| 916 |
var $uploader_wrapper = $uploader_trigger.closest('.os-multiple-files-uploader'); |
| 917 |
var $files_list = $uploader_wrapper.find('.os-uploaded-files-list'); |
| 918 |
var $file_ids_holder = $uploader_wrapper.find('.os-file-ids-holder'); |
| 919 |
|
| 920 |
// Create a new media frame |
| 921 |
frame = wp.media({ |
| 922 |
title: 'Select or Upload Files', |
| 923 |
button: { text: 'Add selected files' }, |
| 924 |
multiple: 'add' // Allows to select multiple files |
| 925 |
}); |
| 926 |
|
| 927 |
// When files are selected... |
| 928 |
frame.on('select', function() { |
| 929 |
var attachments = frame.state().get('selection').map(function(attachment) { |
| 930 |
attachment = attachment.toJSON(); |
| 931 |
return attachment; |
| 932 |
}); |
| 933 |
|
| 934 |
var current_ids = $file_ids_holder.val() ? $file_ids_holder.val().split(',') : []; |
| 935 |
|
| 936 |
attachments.forEach(function(attachment) { |
| 937 |
// Skip if file already added |
| 938 |
if(current_ids.indexOf(attachment.id.toString()) !== -1) return; |
| 939 |
|
| 940 |
// Add to IDs list |
| 941 |
current_ids.push(attachment.id); |
| 942 |
|
| 943 |
// Add to files list |
| 944 |
var $file_item = jQuery('<div class="os-uploaded-file" data-file-id="'+attachment.id+'">'); |
| 945 |
$file_item.append('<a class="os-file-link" href="'+attachment.url+'" target="_blank">'+attachment.filename+'</a>'); |
| 946 |
$file_item.append('<a href="#" class="os-remove-file" title="'+$uploader_trigger.data('label-remove-str')+'"><i class="latepoint-icon latepoint-icon-cross"></i></a>'); |
| 947 |
$files_list.append($file_item); |
| 948 |
}); |
| 949 |
|
| 950 |
// Update hidden field with all IDs |
| 951 |
$file_ids_holder.val(current_ids.join(',')); |
| 952 |
}); |
| 953 |
|
| 954 |
frame.open(); |
| 955 |
return false; |
| 956 |
}); |
| 957 |
|
| 958 |
jQuery('.latepoint-admin').on('click', '.os-remove-file', function(event) { |
| 959 |
event.preventDefault(); |
| 960 |
|
| 961 |
let $remove_btn = jQuery(this); |
| 962 |
const confirm_text = $remove_btn.closest('.os-uploaded-files-list').data('confirm-text') || 'Are you sure you want to remove this file?'; |
| 963 |
if (confirm(confirm_text)) { |
| 964 |
let $file_item = $remove_btn.closest('.os-uploaded-file'); |
| 965 |
let $file_ids_holder = $file_item.closest('.os-multiple-files-uploader').find('.os-file-ids-holder'); |
| 966 |
|
| 967 |
let file_id = $file_item.data('file-id'); |
| 968 |
let current_ids = $file_ids_holder.val() ? $file_ids_holder.val().split(',') : []; |
| 969 |
|
| 970 |
current_ids = current_ids.filter(function(id) { |
| 971 |
return id != file_id; |
| 972 |
}); |
| 973 |
|
| 974 |
$file_ids_holder.val(current_ids.join(',')); |
| 975 |
$file_item.remove(); |
| 976 |
} |
| 977 |
}); |
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
jQuery('body').on('click', '.latepoint-lightbox-close', function(){ |
| 982 |
latepoint_lightbox_close(); |
| 983 |
return false; |
| 984 |
}); |
| 985 |
|
| 986 |
|
| 987 |
jQuery('body').on('click', '.latepoint-side-panel-close-trigger', function(){ |
| 988 |
latepoint_close_side_panel(); |
| 989 |
return false; |
| 990 |
}); |
| 991 |
jQuery('body').on('click', '.latepoint-side-sub-panel-close-trigger', function(){ |
| 992 |
jQuery(this).closest('.side-sub-panel-wrapper').remove(); |
| 993 |
return false; |
| 994 |
}); |
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
jQuery('body.latepoint-admin').on('click', '.time-ampm-select', function(){ |
| 999 |
let $form = jQuery(this).closest('.order-item-booking-data-form-wrapper'); |
| 1000 |
jQuery(this).closest('.time-ampm-w').find('.active').removeClass('active'); |
| 1001 |
jQuery(this).addClass('active'); |
| 1002 |
var ampm_value = jQuery(this).data('ampm-value'); |
| 1003 |
jQuery(this).closest('.os-time-group').find('.ampm-value-hidden-holder').val(ampm_value); |
| 1004 |
if(jQuery(this).closest('.quick-start-time-w').length){ |
| 1005 |
// if called from quick edit form - we need to make sure it accurately changes time to next day if end time is earlier than start time |
| 1006 |
latepoint_set_booking_end_time($form); |
| 1007 |
latepoint_is_next_day($form); |
| 1008 |
} |
| 1009 |
if(jQuery(this).closest('.quick-end-time-w').length){ |
| 1010 |
latepoint_is_next_day($form); |
| 1011 |
} |
| 1012 |
return false; |
| 1013 |
}); |
| 1014 |
|
| 1015 |
|
| 1016 |
jQuery('body.latepoint-admin').on('click', '.latepoint-lightbox-shadow', function(){ |
| 1017 |
latepoint_lightbox_close(); |
| 1018 |
return false; |
| 1019 |
}); |
| 1020 |
|
| 1021 |
jQuery('body.latepoint-admin').on('click', '.latepoint-side-panel-shadow', function(){ |
| 1022 |
jQuery('.latepoint-side-panel-w').remove(); |
| 1023 |
return false; |
| 1024 |
}); |
| 1025 |
|
| 1026 |
// SCHEDULE |
| 1027 |
|
| 1028 |
jQuery('body.latepoint-admin').on('click', '.ws-period-remove', function(e){ |
| 1029 |
jQuery(this).closest('.ws-period').remove(); |
| 1030 |
return false; |
| 1031 |
}); |
| 1032 |
|
| 1033 |
|
| 1034 |
jQuery('.latepoint-admin').on( 'click', '.weekday-schedule-w .os-toggler', function( event ){ |
| 1035 |
if(jQuery(this).hasClass('off')){ |
| 1036 |
jQuery(this).closest('.weekday-schedule-w').addClass('day-off').removeClass('is-editing').find('input.is-active').val(0); |
| 1037 |
}else{ |
| 1038 |
jQuery(this).closest('.weekday-schedule-w').removeClass('day-off').addClass('is-editing').find('input.is-active').val(1); |
| 1039 |
} |
| 1040 |
return false; |
| 1041 |
}); |
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
}); |
| 1046 |
|