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