File: /var/www/iranga.kauko.lt/wp-content/plugins/woocommerce-bookings.bad/assets/js/writepanel.min.js
jQuery(document).ready(function(n){function o(){n(".wc_booking_availability_type select, .wc_booking_pricing_type select, #_wc_booking_duration_type, #_wc_booking_user_can_cancel, #_wc_booking_duration_unit, #_wc_booking_has_persons, #_wc_booking_has_resources, #_wc_booking_has_person_types, #_wc_booking_has_restricted_days").change()}n("#bookings_availability, #bookings_pricing, .bookings_extension").on("change",".wc_booking_availability_type select, .wc_booking_pricing_type select",function(){var e=n(this).val(),o=n(this).closest("tr"),r=n(o);r.find(".from_date, .from_day_of_week, .from_month, .from_week, .from_time, .from").hide(),r.find(".to_date, .to_day_of_week, .to_month, .to_week, .to_time, .to").hide(),r.find(".repeating-label").hide(),r.find(".bookings-datetime-select-to").removeClass("bookings-datetime-select-both"),r.find(".bookings-datetime-select-from").removeClass("bookings-datetime-select-both"),r.find(".bookings-to-label-row .bookings-datetimerange-second-label").hide(),"custom"==e&&r.find(".from_date, .to_date").show(),"months"==e&&r.find(".from_month, .to_month").show(),"weeks"==e&&r.find(".from_week, .to_week").show(),"days"==e&&r.find(".from_day_of_week, .to_day_of_week").show(),e.match("^time")&&(r.find(".from_time, .to_time").show(),"time:range"===e&&(r.find(".from_date, .to_date").show(),r.find(".repeating-label").show(),r.find(".bookings-datetime-select-to").addClass("bookings-datetime-select-both"),r.find(".bookings-datetime-select-from").addClass("bookings-datetime-select-both"),r.find(".bookings-to-label-row .bookings-datetimerange-second-label").show())),"persons"!=e&&"duration"!=e&&"blocks"!=e||r.find(".from, .to").show()}),n("body").on("row_added",function(){n(".wc_booking_availability_type select, .wc_booking_pricing_type select").change(),n(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:wc_bookings_writepanel_js_params.calendar_image,buttonImageOnly:!0})}),n("body").on("woocommerce-product-type-change",function(e){"booking"!==e&&(n("#_wc_booking_has_persons").removeAttr("checked"),n("#_wc_booking_has_resources").removeAttr("checked")),o()}),n("input#_virtual").change(function(){o()}),n("#_wc_booking_duration_type").change(function(){"customer"==n(this).val()?n("#min_max_duration").show():n("#min_max_duration").hide()}),n("#_wc_booking_duration_unit").change(function(){switch(n(".availability_time, ._wc_booking_first_block_time_field").hide(),n("#enable-range-picker").hide(),n("._wc_booking_apply_adjacent_buffer_field").show(),n("._wc_booking_buffer_period").show(),n(this).val()){case"hour":case"minute":var e="hour"===n(this).val()?wc_bookings_writepanel_js_params.i18n_hours:wc_bookings_writepanel_js_params.i18n_minutes;n("._wc_booking_buffer_period_unit").text(e),n(".availability_time, ._wc_booking_first_block_time_field").show();break;case"month":n("._wc_booking_buffer_period").hide(),n("._wc_booking_apply_adjacent_buffer_field").hide();break;default:n("#enable-range-picker").show(),n("._wc_booking_buffer_period_unit").text(wc_bookings_writepanel_js_params.i18n_days)}}),n("#_wc_booking_user_can_cancel").change(function(){n(this).is(":checked")?n(".form-field.booking-cancel-limit").show():n(".form-field.booking-cancel-limit").hide()}),n("#_wc_booking_has_persons").change(function(){n(this).is(":checked")?n("#persons-options, .bookings_persons_tab").show():n("#persons-options, .bookings_persons_tab").hide(),n("ul.wc-tabs li:visible").eq(0).find("a").click()}),n("#_wc_booking_has_person_types").change(function(){n(this).is(":checked")?n("#persons-types").show():n("#persons-types").hide()}),n("#_wc_booking_has_resources").change(function(){n(this).is(":checked")?n(".bookings_resources_tab").show():n(".bookings_resources_tab").hide(),n("ul.wc-tabs li:visible").eq(0).find("a").click()}),n("#_wc_booking_has_restricted_days").change(function(){n(this).is(":checked")?n(".booking-day-restriction").show():n(".booking-day-restriction").hide()}),o(),n("#availability_rows, #pricing_rows").sortable({items:"tr",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(e,o){o.item.css("background-color","#f6f6f6")},stop:function(e,o){o.item.removeAttr("style"),jQuery(e.target).find("tr").each(function(e,o){for(var r=jQuery(o).find('[name*="wc_booking"]'),n=0;n<r.length;n++){var i=r[n],t=jQuery(i).attr("name"),s=t.replace(/[\d+]/g,e);s!==t&&jQuery(i).attr("name",s)}})}}),n(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:wc_bookings_writepanel_js_params.calendar_image,buttonImageOnly:!0}),n(".add_row").click(function(e){var o=n(e.target).closest("table").find("#pricing_rows tr").length,r=n(this).data("row");return r=r.replace(/bookings_cost_js_index_replace/gi,o.toString()),n(this).closest("table").find("tbody").append(r),n("body").trigger("row_added"),!1}),n("body").on("click","td.remove",function(){return n(this).closest("tr").remove(),!1}),n("#bookings_persons").on("change","input.person_name",function(){n(this).closest(".woocommerce_booking_person").find("span.person_name").text(n(this).val())}),jQuery("#bookings_persons").on("click","button.add_person",function(){jQuery(".woocommerce_bookable_persons").block({message:null});var e=jQuery(".woocommerce_booking_person").length,o={action:"woocommerce_add_bookable_person",post_id:wc_bookings_writepanel_js_params.post,loop:e,security:wc_bookings_writepanel_js_params.nonce_add_person};return jQuery.post(wc_bookings_writepanel_js_params.ajax_url,o,function(e){jQuery(".woocommerce_bookable_persons").append(e).unblock(),jQuery(".woocommerce_bookable_persons #message").hide(),n(".woocommerce_bookable_persons").sortable(r)}),!1}),jQuery("#bookings_persons").on("click","button.unlink_booking_person",function(e){if(e.preventDefault(),confirm(wc_bookings_writepanel_js_params.i18n_remove_person)){var o=jQuery(this).parent().parent(),r=jQuery(this).attr("rel");if(0<r){jQuery(o).block({message:null});var n={action:"woocommerce_unlink_bookable_person",person_id:r,security:wc_bookings_writepanel_js_params.nonce_unlink_person};jQuery.post(wc_bookings_writepanel_js_params.ajax_url,n,function(e){jQuery(o).fadeOut("300",function(){jQuery(o).remove()})})}else jQuery(o).fadeOut("300",function(){jQuery(o).remove()})}return!1});var r={items:".woocommerce_booking_person",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(e,o){o.item.css("background-color","#f6f6f6")},stop:function(e,o){o.item.removeAttr("style"),n(".woocommerce_bookable_persons .woocommerce_booking_person").each(function(e,o){n(".person_menu_order",o).val(parseInt(n(o).index(".woocommerce_bookable_persons .woocommerce_booking_person"),10))})}};n(".woocommerce_bookable_persons").sortable(r),n("#bookings_resources").on("change","input.resource_name",function(){n(this).closest(".woocommerce_booking_resource").find("span.resource_name").text(n(this).val())}),jQuery("#bookings_resources").on("click","button.add_resource",function(){var e=jQuery(".woocommerce_booking_resource").length,o=jQuery("select.add_resource_id").val(),r="";if(!o&&!(r=prompt(wc_bookings_writepanel_js_params.i18n_new_resource_name)))return!1;jQuery(".woocommerce_bookable_resources").block({message:null});var n={action:"woocommerce_add_bookable_resource",post_id:wc_bookings_writepanel_js_params.post,loop:e,add_resource_id:o,add_resource_name:r,security:wc_bookings_writepanel_js_params.nonce_add_resource};return jQuery.post(wc_bookings_writepanel_js_params.ajax_url,n,function(e){e.error?alert(e.error):(jQuery(".woocommerce_bookable_resources").append(e.html).unblock(),jQuery(".woocommerce_bookable_resources").sortable(i),o&&jQuery(".add_resource_id").find("option[value="+o+"]").remove())}),!1}),jQuery("#bookings_resources").on("click","button.remove_booking_resource",function(e){if(e.preventDefault(),confirm(wc_bookings_writepanel_js_params.i18n_remove_resource)){var r=jQuery(this).parent().parent(),o=jQuery(this).attr("rel");jQuery(r).block({message:null,overlayCSS:{background:"#fff url("+wc_bookings_writepanel_js_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var n={action:"woocommerce_remove_bookable_resource",post_id:wc_bookings_writepanel_js_params.post,resource_id:o,security:wc_bookings_writepanel_js_params.nonce_delete_resource};jQuery.post(wc_bookings_writepanel_js_params.ajax_url,n,function(e){jQuery(r).fadeOut("300",function(){jQuery(r).remove();var e=jQuery(r).find("input[name*=resource_id]").val(),o=jQuery(r).find("input[name*=resource_title]").val();jQuery("select[name=add_resource_id]").append(jQuery("<option>",{value:e,text:o}))})})}return!1});var i={items:".woocommerce_booking_resource",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(e,o){o.item.css("background-color","#f6f6f6")},stop:function(e,o){o.item.removeAttr("style"),n(".woocommerce_bookable_resources .woocommerce_booking_resource").each(function(e,o){n(".resource_menu_order",o).val(parseInt(n(o).index(".woocommerce_bookable_resources .woocommerce_booking_resource"),10))})}};n(".woocommerce_bookable_resources").sortable(i)});