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(e,i){jQuery("#publish").attr("disabled","disabled"),i.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 i,d=0;jQuery(".um-admin-drag-row").each(function(){d++,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 e=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_"+d)}),i=0,jQuery(".um-admin-drag-col .um-admin-drag-fld").each(function(){var e;jQuery(this).hasClass("group")||(""!=(e=jQuery(this).data("group"))?(0==jQuery(".um-admin-drag-fld.um-field-type-group."+e).find(".um-admin-drag-group").find(jQuery(this)).length&&jQuery(this).appendTo(jQuery(".um-admin-drag-fld.um-field-type-group."+e).find(".um-admin-drag-group")),jQuery(".um_update_order_fields").append('')):jQuery(".um_update_order_fields").append('')),i++,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 e='';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(e)}),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(e)})}function um_builder_delete_field_ajax(i){var e,d;0").append(a.parents("#wp-"+i+"-wrap").clone()),a.parents("#wp-"+i+"-wrap").replaceWith('
'),jQuery(".um-admin-editor:visible").html(jQuery(UM.admin.builder.tinyMCE.editor).html()),d=void 0===tinyMCEPreInit.mceInit[i]?tinyMCEPreInit.mceInit[i]=tinyMCE.extend({},tinyMCEPreInit.mceInit[i]):tinyMCEPreInit.mceInit[i],"function"==typeof QTags&&(QTags(tinyMCEPreInit.qtInit[i]),QTags._buttonsInit()),"object"==typeof window.switchEditors&&window.switchEditors.go(i),tinyMCE.init(d),tinyMCE.get(i).setContent(e),a):(UM.admin.builder.tinyMCE.editor=jQuery("
").append(a.parents("#wp-"+i+"-wrap").clone()),a.parents("#wp-"+i+"-wrap").replaceWith('
'),jQuery(".um-admin-editor:visible").html(jQuery(UM.admin.builder.tinyMCE.editor).html()),"function"==typeof QTags&&(QTags(tinyMCEPreInit.qtInit[i]),QTags._buttonsInit()),jQuery("#"+i))).html(e),jQuery("body").on("click",".wp-switch-editor",function(){var e=jQuery(this);e.hasClass("wp-switch-editor")&&"object"==typeof window.switchEditors&&(e=e.hasClass("switch-tmce")?"tmce":"html",window.switchEditors.go(i,e))})}},previewResize:function(){jQuery(".um-admin-modal-body > .um").length&&(jQuery(".um-admin-modal-body > .um").each(function(){(element_width=jQuery(this).width())<=340?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob340")):element_width<=500?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob500")):element_width<=800?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob800")):element_width<=960?(jQuery(this).removeClass("uimob340"),jQuery(this).removeClass("uimob500"),jQuery(this).removeClass("uimob800"),jQuery(this).removeClass("uimob960"),jQuery(this).addClass("uimob960")):960'+jQuery(".um-col-demon-row").html()+"
"),e.find(".um-admin-drag-row:last").find(".um-admin-drag-row-icons").find("a.um-admin-drag-row-edit").attr("data-arg3","_um_row_"+e.find(".um-admin-drag-row").length),e.find(".um-admin-drag-row:last").attr("data-original","_um_row_"+e.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 e=jQuery(this),i=jQuery(this).data("remove_element"),d=jQuery(this).parents("."+i).children(".um-admin-row-loading");var a=jQuery(this).parents(".um-admin-drag-row").index(),n=jQuery(this).parents(".um-admin-drag-rowsub").index();let r={row:a,subrow:n},o=!1;jQuery.each(UM.admin.builder.deleteProcess,function(e){if(r.row===UM.admin.builder.deleteProcess[e].row&&r.subrow===UM.admin.builder.deleteProcess[e].subrow)return!(o=!0)}),o||(d.show(),UM.admin.builder.deleteProcess.push({row:a,subrow:n}),UM.admin.builder.fieldsToDelete=jQuery(this).parents("."+i).find(".um-admin-drag-fld").toArray(),0');e.find(".um-admin-drag-col").removeClass("cols-1 cols-2 cols-3 cols-last cols-middle"),e.find(".um-admin-drag-col").addClass("cols-"+e.find(".um-admin-drag-col").length),e.find(".um-admin-drag-col:last").addClass("cols-last"),3==e.find(".um-admin-drag-col").length&&e.find(".um-admin-drag-col:eq(1)").addClass("cols-middle")}else n<0&&(2==(n+=3)&&(e.find(".um-admin-drag-col:first").append(e.find(".um-admin-drag-col.cols-last").html()),e.find(".um-admin-drag-col.cols-last").remove()),1==n&&(e.find(".um-admin-drag-col:first").append(e.find(".um-admin-drag-col.cols-last").html()),e.find(".um-admin-drag-col:first").append(e.find(".um-admin-drag-col.cols-middle").html()),e.find(".um-admin-drag-col.cols-last").remove(),e.find(".um-admin-drag-col.cols-middle").remove()),e.find(".um-admin-drag-col").removeClass("cols-1 cols-2 cols-3 cols-last cols-middle"),e.find(".um-admin-drag-col").addClass("cols-"+e.find(".um-admin-drag-col:visible").length),e.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()});