function UM_Drag_and_Drop(){jQuery(".um-admin-drag-col,.um-admin-drag-group").sortable({items:".um-admin-drag-fld",connectWith:".um-admin-drag-col,.um-admin-drag-group",placeholder:"um-fld-placeholder",forcePlaceholderSize:!0,update:function(d,a){jQuery("#publish").attr("disabled","disabled"),a.item.hasClass("um-field-type-group")&&0')})}function UM_update_subrows(){jQuery('a[data-remove_element="um-admin-drag-rowsub"]').remove(),jQuery(".um-admin-drag-row").each(function(){c=0,jQuery(this).find(".um-admin-drag-rowsub").each(function(){c++,row=jQuery(this),1!=c&&row.find(".um-admin-drag-rowsub-icons").append('')})})}function UM_Change_Field_Col(){jQuery(".um-admin-drag-col .um-admin-drag-fld").each(function(){cols=jQuery(this).parents(".um-admin-drag-rowsub").find(".um-admin-drag-col").length,(col=jQuery(this).parents(".um-admin-drag-col")).hasClass("cols-last")?(1==cols&&(saved_col=1),3==cols?saved_col=3:2==cols&&(saved_col=2)):saved_col=col.hasClass("cols-middle")&&3==cols?2:1,jQuery(this).data("column",saved_col)})}function UM_Change_Field_Grp(){jQuery(".um-admin-drag-col .um-admin-drag-fld:not(.um-field-type-group)").each(function(){0==jQuery(this).parents(".um-admin-drag-group").length?jQuery(this).data("group",""):jQuery(this).data("group",jQuery(this).parents(".um-admin-drag-fld.um-field-type-group").data("key"))})}function UM_Rows_Refresh(){jQuery(".um_update_order_fields").empty();var a,e=0;jQuery(".um-admin-drag-row").each(function(){e++,row=jQuery(this),col_num="",row.find(".um-admin-drag-rowsub").each(function(){(subrow=jQuery(this)).find(".um-admin-drag-col").removeClass("cols-1 cols-2 cols-3 cols-last cols-middle"),subrow.find(".um-admin-drag-col").addClass("cols-"+subrow.find(".um-admin-drag-col").length),subrow.find(".um-admin-drag-col:last").addClass("cols-last"),3==subrow.find(".um-admin-drag-col").length&&subrow.find(".um-admin-drag-col:eq(1)").addClass("cols-middle"),col_num=col_num?col_num+":"+subrow.find(".um-admin-drag-col").length:subrow.find(".um-admin-drag-col").length}),jQuery(".um_update_order_fields").append(''),sub_rows_count=row.find(".um-admin-drag-rowsub").length;var d=jQuery(this).attr("data-original");jQuery(".um_update_order_fields").append(''),jQuery(".um_update_order_fields").append(''),jQuery(".um_update_order_fields").append(''),jQuery(this).attr("data-original","_um_row_"+e)}),a=0,jQuery(".um-admin-drag-col .um-admin-drag-fld").each(function(){var d;jQuery(this).hasClass("group")||(""!=(d=jQuery(this).data("group"))?(0==jQuery(".um-admin-drag-fld.um-field-type-group."+d).find(".um-admin-drag-group").find(jQuery(this)).length&&jQuery(this).appendTo(jQuery(".um-admin-drag-fld.um-field-type-group."+d).find(".um-admin-drag-group")),jQuery(".um_update_order_fields").append('')):jQuery(".um_update_order_fields").append('')),a++,row="_um_row_"+(row=jQuery(this).parents(".um-admin-drag-row").index()+1),3==(saved_col=jQuery(this).data("column"))&&jQuery(this).appendTo(jQuery(this).parents(".um-admin-drag-rowsub").find(".um-admin-drag-col:eq(2)")),2==saved_col&&jQuery(this).appendTo(jQuery(this).parents(".um-admin-drag-rowsub").find(".um-admin-drag-col:eq(1)")),sub_row=jQuery(this).parents(".um-admin-drag-rowsub").index(),jQuery(".um_update_order_fields").append(''),jQuery(".um_update_order_fields").append(''),jQuery(".um_update_order_fields").append(''),jQuery(".um_update_order_fields").append('')}),UM_Drag_and_Drop(),UM_Add_Icon(),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",data:jQuery(".um_update_order").serialize(),success:function(){jQuery("#publish").prop("disabled",!1)}})}function UM_Add_Icon(){var d='';jQuery(".um-admin-drag-col").each(function(){0==jQuery(this).find(".um-admin-drag-add-field").length||jQuery(this).find(".um-admin-drag-add-field").remove(),jQuery(this).append(d)}),jQuery(".um-admin-drag-group").each(function(){0==jQuery(this).find(".um-admin-drag-add-field").length||jQuery(this).find(".um-admin-drag-add-field").remove(),jQuery(this).append(d)})}function um_builder_delete_field_ajax(a){var d,e;0'+jQuery(".um-col-demon-row").html()+""),d.find(".um-admin-drag-row:last").find(".um-admin-drag-row-icons").find("a.um-admin-drag-row-edit").attr("data-arg3","_um_row_"+d.find(".um-admin-drag-row").length),d.find(".um-admin-drag-row:last").attr("data-original","_um_row_"+d.find(".um-admin-drag-row").length),UM_update_rows(),UM_update_subrows(),UM_Rows_Refresh()}),jQuery(document.body).on("click",'*[data-row_action="add_subrow"]',function(){jQuery(this).parents(".um-admin-drag-row").find(".um-admin-drag-rowsubs").append('
'+jQuery(".um-col-demon-subrow").html()+"
"),UM_update_subrows(),UM_Rows_Refresh()}),jQuery(document.body).on("click",'a[data-remove_element^="um-"]',function(){let d=jQuery(this),a=jQuery(this).data("remove_element"),e=jQuery(this).parents("."+a).children(".um-admin-row-loading");var i=jQuery(this).parents(".um-admin-drag-row").index(),n=jQuery(this).parents(".um-admin-drag-rowsub").index();let r={row:i,subrow:n},o=!1;jQuery.each(UM.admin.builder.deleteProcess,function(d){if(r.row===UM.admin.builder.deleteProcess[d].row&&r.subrow===UM.admin.builder.deleteProcess[d].subrow)return!(o=!0)}),o||(e.show(),UM.admin.builder.deleteProcess.push({row:i,subrow:n}),UM.admin.builder.fieldsToDelete=jQuery(this).parents("."+a).find(".um-admin-drag-fld").toArray(),0');d.find(".um-admin-drag-col").removeClass("cols-1 cols-2 cols-3 cols-last cols-middle"),d.find(".um-admin-drag-col").addClass("cols-"+d.find(".um-admin-drag-col").length),d.find(".um-admin-drag-col:last").addClass("cols-last"),3==d.find(".um-admin-drag-col").length&&d.find(".um-admin-drag-col:eq(1)").addClass("cols-middle")}else n<0&&(2==(n+=3)&&(d.find(".um-admin-drag-col:first").append(d.find(".um-admin-drag-col.cols-last").html()),d.find(".um-admin-drag-col.cols-last").remove()),1==n&&(d.find(".um-admin-drag-col:first").append(d.find(".um-admin-drag-col.cols-last").html()),d.find(".um-admin-drag-col:first").append(d.find(".um-admin-drag-col.cols-middle").html()),d.find(".um-admin-drag-col.cols-last").remove(),d.find(".um-admin-drag-col.cols-middle").remove()),d.find(".um-admin-drag-col").removeClass("cols-1 cols-2 cols-3 cols-last cols-middle"),d.find(".um-admin-drag-col").addClass("cols-"+d.find(".um-admin-drag-col:visible").length),d.find(".um-admin-drag-col:last").addClass("cols-last"));1==allow_update_via_col_click&&(UM_Change_Field_Col(),UM_Rows_Refresh())}),allow_update_via_col_click=!1,jQuery(".um-admin-drag-ctrls.columns a.active").each(function(){jQuery(this).trigger("click")}).promise().done(function(){allow_update_via_col_click=!0}),UM_Rows_Refresh()});