From 8353e79cfb8ad8096a2a1d5752c1217086acc651 Mon Sep 17 00:00:00 2001 From: Serhiy Zakharchenko Date: Fri, 6 Dec 2024 07:55:49 -0800 Subject: [PATCH] Handle form blocking based on invalid fields visibility #2159 --- assets/js/admin-views.js | 4 ++++ assets/js/admin-views.min.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/assets/js/admin-views.js b/assets/js/admin-views.js index 5bf61a39c..7bf8bc449 100644 --- a/assets/js/admin-views.js +++ b/assets/js/admin-views.js @@ -376,6 +376,10 @@ * @param {Event} event */ changedSettingsAction: function (event) { + // Make sure that form is blocked if invalid fields become active and unblocked when they become hidden. + var hasVisibleErrorFields = viewGeneralSettings.metaboxObj.find('.gv-error:visible').length > 0; + hasVisibleErrorFields ? viewConfiguration.disable_publish() : viewConfiguration.enable_publish(); + viewConfiguration.validateField( $( event.target ) ); viewConfiguration.zebraStripeSettings(); }, diff --git a/assets/js/admin-views.min.js b/assets/js/admin-views.min.js index 041ca7e5c..35acd0d85 100644 --- a/assets/js/admin-views.min.js +++ b/assets/js/admin-views.min.js @@ -1 +1 @@ -!function($){var viewConfiguration,viewGeneralSettings;$.widget.bridge("gvTooltip",$.ui.tooltip);const $spinner=$('');viewConfiguration={startFreshStatus:!1,hasUnsavedChanges:!1,altKey:!1,dialogWidth:750,performingAjaxAction:!1,init:function(){var vcfg=viewConfiguration;vcfg.gvSelectForm=$("#gravityview_form_id"),vcfg.gvSwitchView=$("#gv_switch_view_button"),vcfg.currentFormId=vcfg.gvSelectForm.val(),vcfg.currentDirectoryTemplate=$("#gravityview_directory_template").val(),vcfg.currentSingletemplate=$("#gravityview_single_template").val(),vcfg.directAccessSelect=$("#gv-direct-access-select"),vcfg.toggleInitialVisibility(vcfg),$(document.body).on("keydown keyup",vcfg.altKeyListener).on("change","#gravityview_form_id",vcfg.formChange).on("click",'a[href="#gv_start_fresh"]',vcfg.startFresh).on("click","#publish, #save-post",vcfg.processFormSubmit).on("submit","#post",vcfg.processFormSubmit).on("click",".gv-view-types-hover",vcfg.selectTemplateHover).on("click","a[rel*=external]",vcfg.openExternalLinks).on("click mouseup keyup",vcfg.closeTooltips).on("click",'.gv-field-filter-form span[role="button"]',vcfg.switchTooltipLayout).on("click","#gv_switch_view_button",vcfg.switchView).on("click",".clear-all-fields",vcfg.removeAllFields).on("click",".gv_select_template",vcfg.selectTemplate).on("change","select[data-view-dropdown]",vcfg.selectTemplate).on("click",".ui-tooltip-content .gv-fields",vcfg.startAddField).on("click",".gv-add-field-before",function(){$(this).closest(".active-drop-container").find("a.gv-add-field").trigger("click",{before:$(this).closest(".gv-fields")})}).on("click",".gv-field-duplicate",vcfg.duplicateField).on("click","#gv-direct-access .edit-direct-access",vcfg.editDirectAccess).on("click","#gv-direct-access-select .cancel-direct-access",vcfg.cancelDirectAccess).on("click","#gv-direct-access-select .save-direct-access",vcfg.updateDirectAccess).on("gravityview_form_change",vcfg.updateFormLinks).on("gravityview_form_change",vcfg.updateWidgetFormIds).on("change",".gv-dialog-options input[name*=show_as_link]",vcfg.toggleShowAsEntry).on("change",".gv-dialog-options input[name*=only_loggedin]",vcfg.toggleCustomVisibility).on("change",".gv-dialog-options [name*=allow_edit_cap]",vcfg.toggleCustomVisibility).on("click",".gv-field-controls .gv-remove-field",vcfg.removeField).on("click",".gv-field-controls .gv-field-settings",vcfg.openFieldSettings).on("dblclick",".gv-fields:not(.gv-nonexistent-form-field)",vcfg.openFieldSettings).on("change","#gravityview_settings",vcfg.changedSettingsAction).on("click",".gv-field-details--toggle",function(e){var $dialog=$(this).parents(".ui-dialog"),was_closed=$(".gv-field-details",$dialog).hasClass("gv-field-details--closed");return viewConfiguration.toggleFieldDetails($dialog,was_closed),$.cookie("gv-field-details-expanded",was_closed,{path:gvGlobals.admin_cookiepath}),!1}).on("search keydown keyup",".gv-field-filter-form input:visible",vcfg.setupFieldFilters).on("click",".gv-section .is-dismissible .notice-dismiss",function(e){var warning_name=$(this).parents(".gv-section").attr("id")+"-"+$("#post_ID").val();$.cookie("warning-dismissed-"+warning_name,1,{path:gvGlobals.admin_cookiepath}),$(document.body).trigger("gravityview/tabs-ready")}).on("gravityview/loaded gravityview/tabs-ready gravityview/field-added gravityview/field-removed gravityview/all-fields-removed gravityview/show-as-entry gravityview/view-config-updated",vcfg.toggleTabConfigurationWarnings).on("gravityview/loaded gravityview/tabs-ready gravityview/field-added gravityview/field-removed gravityview/all-fields-removed gravityview/show-as-entry gravityview/view-config-updated",vcfg.toggleRemoveAllFields).on("search keydown keyup",".gv-field-filter-form input:visible",vcfg.setupFieldFilters).on("gravityview/loaded",function(){$(".gv-setting-list, #gravityview_settings").on("change",vcfg.toggleCheckboxes).trigger("change")}).on("change",".gv-dialog-options",vcfg.toggleCheckboxes).on("focus",".gv-add-field",function(e){$(this).parent(".gv-fields").addClass("trigger--hover")}).on("blur",".gv-add-field",function(e){$(this).parent(".gv-fields").removeClass("trigger--hover")}).on("keydown",".gv-add-field",function(e){return 13!==e.keyCode&&32!==e.keyCode||void $(this).parent(".gv-fields").addClass("trigger--active")}).on("keyup",".gv-add-field",function(e){return 13!==e.keyCode&&32!==e.keyCode||void $(this).parent(".gv-fields").removeClass("trigger--active")}).on("gravityview/dropdown/activate gravityview/dropdown/install",vcfg.enableLockedTemplate),$(window).on("resize",function(){var $open_dialog=$(".ui-dialog:visible").find(".ui-dialog-content");$open_dialog.dialog("option","position",{my:"center",at:"center",of:window});var window_width=vcfg.dialogWidth,ninety_five_per=.95*$(window).width();vcfg.dialogWidth>ninety_five_per&&(window_width=ninety_five_per),$open_dialog.dialog("option","width",window_width)}),window.addEventListener("beforeunload",event=>{vcfg.hasUnsavedChanges&&event.preventDefault()}),gvGlobals.passed_form_id&&vcfg.gvSelectForm.trigger("change");var _sendToEditor=window.send_to_editor;window.send_to_editor=function(val){var cursorPosition=$("#"+window.wpActiveEditor);if(!cursorPosition.hasClass("codemirror")&&_sendToEditor)return _sendToEditor(val);var codeMirror=cursorPosition.next(".CodeMirror")[0].CodeMirror,cursorPosition=codeMirror.getCursor();codeMirror.replaceRange(val,window.wp.CodeMirror.Pos(cursorPosition.line,cursorPosition.ch))},$("div .gform-dropdown__trigger").on("click.gravityforms",vcfg.sendMergeTagValueToCodemirrorEditor)},getCookieVal:function(cookie){return!(!cookie||"undefined"===cookie||"false"===cookie)&&cookie},toggleTabConfigurationWarnings:function(e){var tabs={single:{configured:$(".gv-dialog-options input[name*=show_as_link]:checked","#directory-active-fields").length||$('[data-fieldid="entry_link"]',"#directory-active-fields").length,icon:"dashicons-media-default"},edit:{configured:$('.gv-fields .field-key[value="edit_link"]').length,icon:"dashicons-welcome-write-blog"}};$.each(tabs,function(index,value){var show_warning=index+"-fields-"+$("#post_ID").val(),dismissed_warning=viewConfiguration.getCookieVal($.cookie("warning-dismissed-"+show_warning));const $fields_section=$("#"+index+"-fields");show_warning=$fields_section.find(".active-drop .gv-fields").length,show_warning=!dismissed_warning&&0===value.configured&&0",{class:"gv-error-message",text:error}).insertAfter($field))},validateValue(value,rules){if(rules){var i,validators=viewConfiguration.getValidators();for(i in rules)if(rules.hasOwnProperty(i)){var parts=rules[i],rule=parts.rule,message=parts.message,param="",isValid=!0;if(rule.includes(":")&&(rule=(parts=rule.split(/:(.+)/))[0],param=parts[1]),!(isValid=validators[rule]?validators[rule](value,param):isValid))return message}}},getValidators:function(){return{required:function(value){return null!=value&&""!==value.toString().trim()},max:function(value,max){return null!=value&&Number(value)<=max},min:function(value,min){return null!=value&&Number(value)>=min},email:function(value){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)},integer:function(value){return Number.isInteger?Number.isInteger(Number(value)):Number(value)%1==0},matches:function(value,pattern){return new RegExp(pattern).test(value)}}},zebraStripeSettings:function(){viewGeneralSettings.metaboxObj.find("table").each(function(){var $trs=$(this).find("tr").filter(":visible");$trs.removeClass("alternate"),$trs.filter(":even").addClass("alternate")})},toggleCheckboxes:function($parent){$parent=$parent.currentTarget||$parent;viewConfiguration.toggleRequired($parent,"requires",!1),viewConfiguration.toggleRequired($parent,"requires-not",!0);$parent=$($parent).is(".gv-fields")?$($parent):$($parent).parents(".gv-fields");$parent.length&&(viewConfiguration.toggleDisabled($("input[type=checkbox][name*=link_to_]",$parent),$("input[type=checkbox][name*=show_as_link]",$parent)),viewConfiguration.toggleDisabled($("input[type=checkbox][name*=link_phone]",$parent),$("input[type=checkbox][name*=show_as_link]",$parent)))},toggleDisabled:function($one,$two){0!==$one.length&&0!==$two.length&&($one.is(":checked")?$two.prop("disabled",!0):$two.is(":checked")&&$one.prop("disabled",!0))},toggleRequired:function(currentTarget,data_attr,reverse_logic){var $parent=$(currentTarget,"#post");$parent.find("[data-"+data_attr+"]").each(function(){var $this=$(this),requires_value=$this.data(data_attr).split("="),$input=requires_value[0],requires_value=requires_value[1],$input=$parent.find('[name$="['+$input+']"]').filter(":input");$input.is("[type=checkbox]")?reverse_logic?$this.toggle(0<$input.filter(":not(:checked)").filter(":not(:hidden)").length):$this.toggle($input.is(":checked")):void 0!==requires_value&&(reverse_logic?$this.toggle($input.val()!==requires_value):$this.toggle($input.val()===requires_value))})},switchTooltipLayout:function(e){var layout=$(this).data("value");viewConfiguration.setTooltipLayout(layout)},setTooltipLayout:function(layout){$(".gv-items-picker--"+layout).addClass("active"),$(".gv-items-picker").not(".gv-items-picker--"+layout).removeClass("active"),$(".gv-items-picker-container").attr("data-layout",layout),$.cookie("gv-items-picker-layout",layout,{path:gvGlobals.admin_cookiepath})},closeTooltips:function(e){var activeTooltips=$("[data-tooltip='active']"),close=!1,return_false=!1;switch(e.type){case"keyup":if(27===e.keyCode){if($(".ui-autocomplete").is(":visible"))return;return_false=close=0===$(".gv-field-filter-form input[data-has-search]:focus").length,window.Beacon&&window.Beacon("close")}((13===e.keyCode||32===e.keyCode)&&$(e.target).is(".close")||$(e.target).is(".dashicons-dismiss"))&&(close=!0);break;case"mouseup":$(e.target).parents(".ui-dialog,.ui-tooltip").length||$(e.target).is(".ui-dialog,.ui-tooltip")?close=!1:0vcfg.dialogWidth?vcfg.dialogWidth:$(window).width()-10},open:function(){return $('
').prependTo("#wpwrap"),$(document.body).trigger("gravityview/dialog-opened",thisDialog),vcfg.toggleCheckboxes(thisDialog),vcfg.setupFieldDetails(thisDialog),vcfg.refresh_merge_tags(thisDialog,function(){vcfg.setupCodeMirror(thisDialog)}),$sortableEls=$('.ui-widget-content[aria-hidden="false"]').find(".active-drop-widget, .active-drop-field"),$sortableEls.length&&$sortableEls.each((i,el)=>{$(el).hasClass("ui-sortable")&&$(el).sortable("disable")}),!0},close:function(e){e.preventDefault(),$("textarea.code",thisDialog).each(function(){$CodeMirror=$(this).next(".CodeMirror"),0!==$CodeMirror.length&&$CodeMirror[0].hasOwnProperty("CodeMirror")&&$CodeMirror[0].CodeMirror.toTextArea()}),thisDialog.find(".merge-tag-support").removeClass("merge-tag-support").addClass("gv-merge-tag-support"),$(".gv-field-settings.active","#gravityview_view_config").removeClass("active"),vcfg.setCustomLabel(thisDialog),$("#wpwrap").find("> .gv-overlay").fadeOut("fast",function(){$(this).remove()}),$sortableEls=$('.ui-widget-content[aria-hidden="false"]').find(".active-drop-widget, .active-drop-field"),$sortableEls.length&&$sortableEls.each((i,el)=>{$(el).hasClass("ui-sortable")&&$(el).sortable("enable")}),vcfg._restoreValue(),$(document.body).trigger("gravityview/dialog-closed",thisDialog)},closeOnEscape:!0,buttons:buttons})},setupCodeMirror:function(dialog){var vcfg=viewConfiguration;$("textarea.code:visible",dialog).each(function(){const codemirrorConfig=$.extend(!0,{},wp.codeEditor.defaultSettings);var $textarea,editorId,mergeTag,initialEditorCursorPos,$autocompleteEl,closeAutocompletion,mergeTags=$(this).data("codemirror");mergeTags&&(codemirrorConfig.codemirror=$.extend({},codemirrorConfig.codemirror,mergeTags));let editor=wp.codeEditor.initialize($(this),codemirrorConfig);($(this).hasClass("merge-tag-support")||$(this).hasClass("gv-merge-tag-support"))&&(editor.codemirror.setSize("95%"),$textarea=$(this),editorId=$textarea.attr("id"),mergeTags=window.gfMergeTags.getAutoCompleteMergeTags($textarea),mergeTag="",initialEditorCursorPos=editor.codemirror.getCursor(),$textarea.parent().find(".all-merge-tags").detach().insertBefore($textarea),$textarea.parent().find("div .gform-dropdown__trigger").on("click.gravityforms",vcfg.sendMergeTagValueToCodemirrorEditor),$textarea.autocomplete({appendTo:$textarea.parent(),minLength:1,position:{my:"center top",at:"center bottom",collision:"none"},source:mergeTags,select:function(event,currentEditorCursorPos){var val=currentEditorCursorPos.item.value.replace(/^{|}$/gm,""),currentEditorCursorPos=editor.codemirror.getCursor();editor.codemirror.replaceRange(val,initialEditorCursorPos,window.wp.CodeMirror.Pos(currentEditorCursorPos.line,currentEditorCursorPos.ch)),editor.codemirror.focus(),editor.codemirror.setCursor(window.wp.CodeMirror.Pos(currentEditorCursorPos.line,currentEditorCursorPos.ch+val.length+1))}}),$autocompleteEl=$textarea.parent().find("ul.ui-autocomplete"),closeAutocompletion=function(){$("#"+editorId).autocomplete("close")},$(document.body).on("keyup",function(e){$autocompleteEl.is(":visible")&&27===e.which&&(e.preventDefault(),closeAutocompletion(),$textarea.focus())}),editor.codemirror.on("mousedown",function(){closeAutocompletion()}),editor.codemirror.on("keydown",function(el,e){$autocompleteEl.is(":visible")&&(38!==e.which&&40!==e.which&&13!==e.which||($autocompleteEl.not(":focus")&&$autocompleteEl.focus(),e.preventDefault()))}),editor.codemirror.on("change",function(e,currentEditorCursorPos){"{}"===currentEditorCursorPos.text[0]&&(initialEditorCursorPos=editor.codemirror.getCursor());currentEditorCursorPos=editor.codemirror.getCursor();"{"!==(mergeTag=editor.codemirror.getRange({ch:initialEditorCursorPos.ch-1,line:initialEditorCursorPos.line},currentEditorCursorPos))[0]?closeAutocompletion():$("#"+editorId).autocomplete("search",mergeTag)}))})},sendMergeTagValueToCodemirrorEditor:function(e){var _activeEditorBackup=window.wpActiveEditor;window.wpActiveEditor=$(e.currentTarget).parentsUntil(".gv-setting-container").find("textarea").attr("id"),window.wpActiveEditor&&window.send_to_editor($(this).data("value")),window.wpActiveEditor=_activeEditorBackup},setupFieldDetails:function(dialog){$(".gv-field-details--container",dialog).insertAfter(".ui-dialog-title:visible");var show_details=$.cookie("gv-field-details-expanded"),show_details=viewConfiguration.getCookieVal(show_details);viewConfiguration.toggleFieldDetails(dialog,show_details),viewConfiguration.migrateSurveyScore(dialog)},migrateSurveyScore:function($dialog){var $score;0===$dialog.parents('[data-inputtype="survey"]').length||($score=$dialog.find(".gv-setting-container-score input"))&&0!=+$score.val()&&$dialog.find('.gv-setting-container-choice_display input[value="score"]').trigger("click").trigger("focus")},toggleFieldDetails:function($dialog,show_details){$parent=$dialog.parent(),$parent.find(".gv-field-details").toggleClass("gv-field-details--closed",!show_details).end().find(".gv-field-details--toggle .dashicons").toggleClass("dashicons-arrow-down",!!show_details).toggleClass("dashicons-arrow-right",!show_details).end()},setCustomLabel:function($label){var custom_label_text=$("[name*=admin_label]",$label),custom_label_text=custom_label_text.length&&custom_label_text.val()?custom_label_text:$("[name*=custom_label]",$label),$label=$label.parents(".gv-fields").find(".gv-field-label-text-container");custom_label_text.length&&(0<(custom_label_text=custom_label_text.val().trim()).length?$label.html(custom_label_text):$label.html($label.attr("data-original-title")))},getSortableFields:function(context,id){return new Promise((resolve,reject)=>{var vcfg=viewConfiguration;$(".gravityview_sort_field").prop("disabled","disabled").empty().append("");var data={action:"gv_sortable_fields_form",nonce:gvGlobals.nonce};void 0!==context&&"preset"===context?data.template_id=id:data.form_id=vcfg.gvSelectForm.val(),$.post(ajaxurl,data,function(response){"false"!==response&&"0"!==response&&$(".gravityview_sort_field").empty().append(response).prop("disabled",null),resolve()})})},hideViewConfig:function(){$("#gravityview_view_config").slideUp(150),$(document).trigger("gv_admin_views_hideViewConfig")},showViewConfig:function(){$("#gravityview_view_config").slideDown(150),viewGeneralSettings.metaboxObj.show(),viewConfiguration.toggleDropMessage(),viewConfiguration.init_tooltips(),$(document).trigger("gv_admin_views_showViewConfig")},switchView:function(vcfg){vcfg.preventDefault(),vcfg.stopImmediatePropagation();vcfg=viewConfiguration;vcfg.templateFilter("custom"),vcfg.toggleViewTypeMetabox()},templateFilter:function(templateType){$(".gv-view-types-module").each(function(){$(this).attr("data-filter")===templateType?$(this).parent().show():$(this).parent().hide()})},_isViewDropDown:function(){return viewConfiguration.wantedTemplate&&void 0!==viewConfiguration.wantedTemplate.data("view-data")},_getCurrentTemplateId(){var section=this._getTemplateSection();return null===section||"directory"===section?this.currentDirectoryTemplate:"single"===section?this.currentSingletemplate:""},_setCurrentTemplateId(template_id){var section=this._getTemplateSection();null!==section&&"directory"!==section||(this.currentDirectoryTemplate=template_id),null!==section&&"single"!==section||(this.currentSingletemplate=template_id)},_getTemplateId:function(use_base_template=!1){const $template=viewConfiguration.wantedTemplate;if(!$template)return"";let template_id=$template.data(use_base_template?"base-template":"templateid");return viewConfiguration._isViewDropDown()&&(template_id=viewConfiguration.wantedTemplate.val(),template_id=String($template.val())),template_id},_getTemplateSection:function(){let section=null;return viewConfiguration._isViewDropDown()&&(section=viewConfiguration.wantedTemplate.data("section")),section},_restoreValue:function(){viewConfiguration._isViewDropDown()&&viewConfiguration.wantedTemplate.data("view-data").restoreValue()},_storeValue:function(){viewConfiguration.wantedTemplate&&(viewConfiguration._isViewDropDown()?viewConfiguration.wantedTemplate.data("view-data").storeValue():$("select[data-view-dropdown]").each(function(){$(this).data("view-data").storeValue()}),this._setCurrentTemplateId(this._getTemplateId()))},selectTemplate:function(slugmatch,currentTemplate){var selectedTemplateId,regexMatch,vcfg=viewConfiguration;void 0!==currentTemplate&&null===currentTemplate.section||(slugmatch.preventDefault(),slugmatch.stopImmediatePropagation(),vcfg.wantedTemplate=$(this),selectedTemplateId=vcfg._getTemplateId(),regexMatch=/(.*?)_(.*?)$/i,slugmatch=(currentTemplate=vcfg._getCurrentTemplateId()).replace(regexMatch,"$2"),slugmatch=selectedTemplateId.replace(regexMatch,"$2")===slugmatch,currentTemplate&&!slugmatch&&vcfg.getConfiguredFields().length?currentTemplate!==selectedTemplateId?vcfg.getConfiguredFields().length?vcfg.showDialog("#gravityview_switch_template_dialog"):(vcfg.toggleViewTypeMetabox(),vcfg.selectTemplateContinue(slugmatch)):(vcfg.toggleViewTypeMetabox(),vcfg.showViewConfig()):($("#gravityview_select_template").slideUp(150),vcfg.selectTemplateContinue(slugmatch),vcfg._storeValue()))},selectTemplateContinue:function(slugmatch){var vcfg=viewConfiguration,selectedTemplateId=vcfg._getTemplateId(),selectedFormId=vcfg.gvSelectForm.val(),changeAllSection=!vcfg._getTemplateSection();changeAllSection&&($parent=vcfg._getTemplateId(),$("#gravityview_directory_template").val($parent).trigger("change",{section:null}),$("#gravityview_single_template").val($parent).trigger("change",{section:null}));var $parent=vcfg.wantedTemplate.parents(".gv-view-types-module");$parent.parents(".gv-grid").find(".gv-view-types-module").removeClass("gv-selected"),$parent.addClass("gv-selected"),vcfg.waiting("start"),vcfg.startFreshStatus?Promise.all([vcfg.getAvailableFields("preset",selectedTemplateId),vcfg.getPresetFields(selectedTemplateId),vcfg.getSortableFields("preset",selectedTemplateId)]).then(function(){$(".ui-tabs-panel").each(function(){vcfg.init_droppables(this)})}):(!slugmatch||changeAllSection?vcfg.updateActiveAreas(selectedTemplateId,+selectedFormId):vcfg.waiting("stop"),changeAllSection&&(vcfg.gvSwitchView.fadeIn(150),vcfg.toggleViewTypeMetabox())),vcfg.currentTemplateId=selectedTemplateId,vcfg.setUnsavedChanges(!0)},server_request:(ajaxRoute,payload)=>{const defer=$.Deferred();viewConfiguration.performingAjaxAction=!0,$(".gv-view-template-notice").hide();var{_wpNonce:nonce,_wpAjaxAction:action,_wpAjaxUrl:url,ajaxRouter,frontendFoundationVersion}=window.gvGlobals.foundation_licenses_router;return $.post(url,{nonce:nonce,action:action,ajaxRouter:ajaxRouter,ajaxRoute:ajaxRoute,frontendFoundationVersion:frontendFoundationVersion,payload:payload}).fail(response=>defer.reject(response.responseText)).done(response=>{response.success?(viewConfiguration.performingAjaxAction=!1,defer.resolve(response)):defer.reject(response.data)}),defer.promise()},selectTemplateHover:function(on_success){const vcfg=viewConfiguration,$link=$(on_success.target),$parent=$link.parents(".gv-view-types-module"),$select=$(this).find(".gv_select_template");if($link.is("[rel=internal]")&&!$link.hasClass("gv-layout-activate")&&!$link.hasClass("gv-layout-install"))return!0;on_success.preventDefault(),on_success.stopImmediatePropagation();var on_fail=error=>{$(".gv-view-template-notice").show().find("p").html(error),document.querySelector(".gv-view-template-notice").scrollIntoView({behavior:"smooth"})},do_always=()=>{vcfg.performingAjaxAction=!1,$link.removeClass("disabled"),$parent.removeClass("active")},on_success=()=>{$parent.find(".gv-view-types-hover > div:eq(0)").hide(),$parent.find(".gv-view-types-hover > div:eq(1)").removeClass("hidden"),$parent.removeClass("gv-view-template-placeholder"),$parent.find("a.gv_select_template").attr("data-templateid",$link.data("templateid")).trigger("click"),vcfg.activateViewSelection($link.data("templateid")),$select.trigger("click")};if($link.hasClass("gv-layout-activate"))return vcfg.performingAjaxAction?void 0:($parent.addClass("active"),$link.addClass("disabled").attr("disabled",!0),$link.html($spinner),void $.when(vcfg.server_request("activate_product",{text_domain:$link.attr("data-template-text-domain")})).then(on_success).always(do_always).fail(on_fail));$link.hasClass("gv-layout-install")&&(vcfg.performingAjaxAction||($parent.addClass("active"),$link.addClass("disabled").attr("disabled",!0),$link.html($spinner),$.when(vcfg.server_request("install_product",{id:$link.attr("data-download-id"),text_domain:$link.attr("data-template-text-domain"),activate:!0})).then(on_success).always(do_always).fail(on_fail)))},enableLockedTemplate:function(e,data){const $option=$(data?.option)||null;var action=data?.action||null,payload={text_domain:$option.data("template-text-domain"),activate:!0};if("{}"!==JSON.stringify(payload)){const $pill=$(e.target),$item=$pill.closest(".view-dropdown-list-item");$pill.addClass("is-idle").html($spinner),$item.addClass("is-idle"),$.when(viewConfiguration.server_request(action+"_product",payload)).then(()=>{$pill.removeClass("has-failed"),viewConfiguration.activateViewSelection($option.data("template-id")),data?.dropdown?.focusActive()}).fail(error=>{$pill.addClass("has-failed").text("Error"),console.log(error)}).always(()=>{$pill.removeClass("is-idle"),$item.removeClass("is-idle")})}},activateViewSelection:function(template_id){const $view_selectors=$("[data-view-dropdown]"),$options=$view_selectors.find('option[data-template-id="'+template_id+'"]');$options.attr("disabled",!1),$options.val(template_id),$view_selectors.each((_,el)=>{const dropdown=$(el).viewDropdown();dropdown.renderOptions()}),viewConfiguration.updateSettingsArea()},openExternalLinks:function(){return window.Beacon&&($(this).is("[data-beacon-article]")||$(this).is("[data-beacon-article-modal]")||$(this).is("[data-beacon-article-sidebar]")||$(this).is("[data-beacon-article-inline]"))||window.open(this.href),!1},previewTemplate:function(e){e.preventDefault(),e.stopImmediatePropagation();var parent=$(e.currentTarget).parents(".gv-view-types-module");parent.find(".gv-template-preview").dialog({dialogClass:"wp-dialog gv-dialog",appendTo:$("#gravityview_select_template"),width:viewConfiguration.dialogWidth,open:function(){$('
').prependTo("#wpwrap")},close:function(){$(this).dialog("option","appendTo",parent),$("#wpwrap").find("> .gv-overlay").fadeOut("fast",function(){$(this).remove()})},closeOnEscape:!0,buttons:[{text:gvGlobals.label_close,click:function(){$(this).dialog("close")}}]})},updateActiveAreas:function(template,data){var vcfg=viewConfiguration,data={action:"gv_get_active_areas",template_id:template,form_id:data,nonce:gvGlobals.nonce};return vcfg.updateViewConfig(data)},updateSettingsArea:function(){const $settings_content=$("#gravityview_settings .inside");$settings_content.html(""),$.get(document.URL,function(response){if(response){const $document=$(response);$settings_content.html($document.find("#gravityview_settings .inside").html()),viewGeneralSettings.refresh(),$("#gravityview_directory_template").trigger("change")}})},getPresetFields:function(data){var vcfg=viewConfiguration;$("#directory-active-fields, #single-active-fields").children().remove();data={action:"gv_get_preset_fields",template_id:data,nonce:gvGlobals.nonce};return vcfg.updateViewConfig(data)},updateViewConfig:function(data){return new Promise((resolve,reject)=>{const vcfg=viewConfiguration,section=vcfg._getTemplateSection(),update_directory="directory"===section||null===section,update_single="single"===section||null===section;update_directory&&$("#directory-active-fields").children().remove(),update_single&&$("#single-active-fields").children().remove(),$.post(ajaxurl,data,function(content){content&&(content=JSON.parse(content),update_directory&&($("#directory-header-widgets").html(content.header),$("#directory-footer-widgets").html(content.footer),$("#directory-active-fields").append(content.directory),$("#directory-header-widgets a[data-templateid], #directory-footer-widgets a[data-templateid]").attr("data-templateid",data.template_id).attr("data-formid",data.form_id)),update_single&&$("#single-active-fields").append(content.single),vcfg.showViewConfig(),vcfg.waiting("stop"),$(document.body).trigger("gravityview/view-config-updated",content,section)),resolve()}),vcfg.setUnsavedChanges(!0)})},waiting:function(action){$containers=$("#wpwrap,.gv-fields"),"start"===action?$containers.addClass("gv-wait"):$containers.removeClass("gv-wait")},remove_tooltips:function(el){$(el||".gv-add-field").is(":ui-tooltip")&&$(".gv-add-field").gvTooltip("destroy").off("click")},init_tooltips:function(el){0!==$(el||".gv-add-field","#post").not(":ui-tooltip").length&&$(el||".gv-add-field","#post").gvTooltip({show:150,hide:200,content:function(){var context=$(this).attr("data-context"),formId=$(this).attr("data-formid")||$("#gravityview_form_id").val(),templateId=$("#gravityview_directory_template").val();switch($(this).attr("data-objecttype")){case"field":return $("#"+context+"-available-fields-"+(formId||templateId)).html();case"widget":return $("#directory-available-widgets").html()}},close:function(){$(this).attr("data-tooltip",null)},open:function(event,tooltip){$(this).attr("data-tooltip","active").attr("data-tooltip-id",$(this).attr("aria-describedby")),$focus_item=$("input[type=search]",tooltip.tooltip),$focus_item.length||($focus_item=$(tooltip.tooltip).find(".close").first());var box="list";$(tooltip).find(".gv-items-picker-container[data-layout]").length?box=$(tooltip).find(".gv-items-picker-container[data-layout]").attr("data-layout"):(layout_cookie=$.cookie("gv-items-picker-layout"),viewConfiguration.getCookieVal(layout_cookie)&&(box=layout_cookie)),viewConfiguration.setTooltipLayout(box),$focus_item[0].focus({preventScroll:!0});box=$focus_item[0].getBoundingClientRect();(box.y<0||box.y>document.body.getBoundingClientRect().height)&&window.scrollTo({left:window.scrollX,top:window.scrollY+box.y+(box.y<0?-60:60),behavior:"smooth"})},closeOnEscape:!0,disabled:!0,position:{my:"center bottom",at:"center top-12"},tooltipClass:"gravityview-item-picker-tooltip top"}).attr("title",function(){return $(this).attr("title")||$(this).data("title")||""}).on("mouseout focusout",e=>e.stopImmediatePropagation()).on("click",function(e,data){$(this).attr("title",""),$(this).data("before",null),data?.before&&$(this).data("before",data.before),e.preventDefault(),$(this).gvTooltip("open")})},setupFieldFilters:function(e){var input=$(this).val().trim(),$tooltip=$(this).parents(".ui-tooltip-content"),$resultsNotFound=$tooltip.find(".gv-no-results");"keydown"!==e.type?($tooltip.find(".gv-fields").show().filter(function(){var match_title=$(this).find(".gv-field-label").attr("data-original-title").match(new RegExp(input,"i")),match_id=$(this).attr("data-fieldid").match(new RegExp(input,"i")),match_parent=!!$(this).attr("data-parent-label")&&$(this).attr("data-parent-label").match(new RegExp(input,"i"));return!match_title&&!match_id&&!match_parent}).hide(),$tooltip.find(".gv-fields:visible").length?$resultsNotFound.hide():$resultsNotFound.show()):$(this).attr("data-has-search",0{var vcfg=viewConfiguration;vcfg.toggleDropMessage(),vcfg.getConfiguredFields().remove();var data={action:"gv_available_fields",nonce:gvGlobals.nonce};data.form_preset_ids=void 0!==preset&&"preset"===preset?[templateid]:[vcfg.gvSelectForm.val()],$("#directory-available-fields-"+data.form_preset_ids[0]).length||$.post(ajaxurl,data,function(response){response.success||response.data||resolve(),$.each(response.data,function(context,markup){$("#"+context+"-fields").append(markup)}),resolve()})})},startAddField:function(e){$(this).has(".field-id-all-fields").length?viewConfiguration.addAllFields($(this)):viewConfiguration.addField($(this),e)},addAllFields:function(clicked){const fields=clicked.siblings(".gv-fields").filter(function(){var field_id=$(this).data("fieldid");return+field_id===parseInt(field_id,10)});!async function(){for(let i=0;inew Promise((resolve,reject)=>{$(document.body).one("gravityview/field-added",function(){resolve()}),$(el).trigger("click")}))(fields[i]);$("a.gv-add-field[data-tooltip='active']").gvTooltip("close")}()},addField:function(clicked,$before){$before.preventDefault();$before=clicked.closest(".ui-tooltip").attr("id");const $addButton=$('.gv-add-field[data-tooltip-id="'+$before+'"]');$before=$addButton.data("before");viewConfiguration.placeField(clicked,$addButton,$before,!!$before)},placeField:function($field,$addButton,$anchor,add_before_anchor=!1){const vcfg=viewConfiguration,$newField=$field.clone().hide();var data={action:"gv_field_options",template:$addButton.attr("data-templateid")??$addButton.parents(".gv-section").find(".view-template-select select").val()??$("#gravityview_directory_template").val(),area:$addButton.attr("data-areaid"),context:$addButton.attr("data-context"),field_id:$newField.attr("data-fieldid"),field_label:$newField.find(".gv-field-label").attr("data-original-title"),field_type:$addButton.attr("data-objecttype"),input_type:$newField.attr("data-inputtype"),form_id:parseInt($field.attr("data-formid"),10)||vcfg.currentFormId,nonce:gvGlobals.nonce};$.ajax({type:"POST",url:ajaxurl,data:data,async:!0,beforeSend:function(){vcfg.disable_publish()},complete:function(){vcfg.enable_publish()}}).done(function(response){var insert_method=/[^\[]+\[[^\]]+\]\[([^\]]+)\].*/i;if(0<$field.find("input.field-key").length){$newField.find(".gv-dialog, .gv-dialog-options").remove();const oldId=$field.find("input.field-key").attr("name").replace(insert_method,"$1"),newId=response.match(insert_method,"$1")[1]??null;response=$(response),$field.find(".gv-dialog-options :input").each(function(i,el){if($(el).attr("name")){const $fields=response.find('[name="'+$(el).attr("name").replaceAll(""+oldId,""+newId)+'"]');1===$fields.length?$fields.val($(el).val()):2===$fields.length&&$(el).is(":checked")&&$fields.prop("checked",!0)}})}$newField.append(response),$(".ui-tabs-panel").each(function(){vcfg.init_droppables(this)}),0<$(".gv-dialog-options",$newField).length&&$(".gv-field-settings",$newField).removeClass("hide-if-js"),$anchor?(insert_method=add_before_anchor?"insertBefore":"insertAfter",$newField[insert_method]($anchor)):$addButton.closest(".gv-droppable-area").find(".active-drop").append($newField),$(document.body).trigger("gravityview/field-added",$newField),$newField.fadeIn(100),vcfg.refreshGFtooltips()}).fail(function(jqXHR){vcfg.enable_publish(),alert(gvGlobals.field_loaderror),console.log(jqXHR)}).always(function(){vcfg.toggleDropMessage(),vcfg.setUnsavedChanges(!0)})},duplicateField:function($field){$field.preventDefault();$field=$(this).closest(".gv-fields");viewConfiguration.placeField($field,$(this).closest(".active-drop-container").find("a.gv-add-field"),$field)},refresh_merge_tags:function($source,onRefresh){let $merge_tag_supported=$source?$(".gv-merge-tag-support,.merge-tag-support",$source):$(".gv-merge-tag-support:visible");if($merge_tag_supported.removeClass("gv-merge-tag-support mt-initialized").addClass("merge-tag-support"),window.gform?.instances?.mergeTags)return $(".all-merge-tags",$source).remove(),document.dispatchEvent(new Event("DOMContentLoaded")),void setTimeout(function(){$merge_tag_supported.removeClass("merge-tag-support").addClass("gv-merge-tag-support"),onRefresh&&onRefresh()},300);"undefined"!=typeof form&&$(document.body).not(".gv-form-changed")&&0<=$merge_tag_supported.length&&(window.gfMergeTags&&($(".all-merge-tags:visible").remove(),gfMergeTags.hasOwnProperty("destroy")?$merge_tag_supported.each(function(){new gfMergeTagsObj(form,$(this))}):window.gfMergeTags=new gfMergeTagsObj(form)),$merge_tag_supported.removeClass("merge-tag-support").addClass("gv-merge-tag-support"),onRefresh&&onRefresh())},enable_publish:function(){$(document).trigger("autosave-enable-buttons.edit-post"),$("#publishing-action").find("#publish").prop("disabled",null).removeClass("button-primary-disabled")},disable_publish:function(){$(document).trigger("autosave-disable-buttons.edit-post"),$("#publishing-action").find("#publish").prop("disabled","disabled").addClass("button-primary-disabled")},init_droppables:function(panel){var vcfg;$(panel).find(".active-drop-field").sortable("instance")||(vcfg=viewConfiguration,$(panel).find(".active-drop-widget").sortable({placeholder:"fields-placeholder",items:"> .gv-fields",distance:2,revert:75,connectWith:".active-drop-widget",start:function(event,ui){$("#directory-fields, #single-fields").find(".active-drop-container-widget").addClass("is-receivable")},stop:function(event,ui){$("#directory-fields, #single-fields").find(".active-drop-container-widget").removeClass("is-receivable")},change:function(event,ui){vcfg.setUnsavedChanges(!0)},receive:function(event,ui){var sender_area=ui.sender.attr("data-areaid"),receiver_area=$(this).attr("data-areaid");ui.item.find('[name^="widgets['+sender_area+']"]').each(function(){var name=$(this).attr("name");$(this).attr("name",name.replace(sender_area,receiver_area))}),vcfg.toggleDropMessage()}}),$(panel).find(".active-drop-field").sortable({placeholder:"fields-placeholder",items:"> .gv-fields",distance:2,revert:75,connectWith:".active-drop-field",start:function(event,ui){$(panel).find(".active-drop-container-field").addClass("is-receivable")},stop:function(event,ui){$(panel).find(".active-drop-container-field").removeClass("is-receivable")},change:function(event,ui){vcfg.setUnsavedChanges(!0)},receive:function(event,ui){var sender_area,receiver_area;0",{name:"gv_fields",value:serialized_data,type:"hidden"})),setTimeout(function(){$post.data("gv-valid",!0),"click"===e.type?$(e.target).trigger("click"):$post.trigger("submit")},101),!1)},createPresetForm:function(e,data){var vcfg=viewConfiguration,$target=$(e.target);e.stopPropagation();data={action:"gv_set_preset_form",template_id:data,nonce:gvGlobals.nonce};return $.ajax({type:"POST",url:ajaxurl,data:data,async:!1,success:function(response){"false"!==response&&"0"!==response?(vcfg.startFreshStatus=!1,vcfg.gvSelectForm.find("option:selected").removeAttr("selected").end().append(response),"click"===e.type?$target.trigger("click"):$("#post").trigger("submit")):$target.before('

'+gvGlobals.label_publisherror+"

")}}),!1}},viewGeneralSettings={templateId:null,metaboxObj:null,init:function(){viewGeneralSettings.metaboxObj=$("#gravityview_settings"),viewGeneralSettings.initTabs(),$("#gravityview_directory_template").on("change",viewGeneralSettings.updateSettingsDisplay),$(document.body).on("gravityview/settings/tab/enable",viewGeneralSettings.enableSettingTab).on("gravityview/settings/tab/disable",viewGeneralSettings.disableSettingTab)},refresh:function(){viewGeneralSettings.metaboxObj.trigger("change"),viewGeneralSettings.metaboxObj.tabs("destroy"),viewGeneralSettings.initTabs()},updateSettingsDisplay:function(){viewGeneralSettings.templateId=$(this).val(),$("tr[data-show-if]").each(viewGeneralSettings.toggleSetting)},toggleSetting:function(){var row=$(this),templates=row.attr("data-show-if");templates.length<1||!viewGeneralSettings.templateId||(0');$(document).on("click",".gk-gravityview-placeholder-actions [data-action]",function(payload){var action;payload.preventDefault(),viewConfiguration.hasUnsavedChanges&&!window.confirm(gvGlobals.discard_unsaved_changes)||$(this).hasClass("is-idle")||($(this).addClass("is-idle").html($spinner),action=$(this).data("action")+"_product",payload={text_domain:$(this).data("text-domain"),activate:!0},$.when(viewConfiguration.server_request(action,payload)).then(response=>{if(!response.success)throw new Error;document.location=document.location}).fail(()=>$(this).removeClass("is-idle").addClass("is-error").text("Try again")))})})}(jQuery); \ No newline at end of file +!function($){var viewConfiguration,viewGeneralSettings;$.widget.bridge("gvTooltip",$.ui.tooltip);const $spinner=$('');viewConfiguration={startFreshStatus:!1,hasUnsavedChanges:!1,altKey:!1,dialogWidth:750,performingAjaxAction:!1,init:function(){var vcfg=viewConfiguration;vcfg.gvSelectForm=$("#gravityview_form_id"),vcfg.gvSwitchView=$("#gv_switch_view_button"),vcfg.currentFormId=vcfg.gvSelectForm.val(),vcfg.currentDirectoryTemplate=$("#gravityview_directory_template").val(),vcfg.currentSingletemplate=$("#gravityview_single_template").val(),vcfg.directAccessSelect=$("#gv-direct-access-select"),vcfg.toggleInitialVisibility(vcfg),$(document.body).on("keydown keyup",vcfg.altKeyListener).on("change","#gravityview_form_id",vcfg.formChange).on("click",'a[href="#gv_start_fresh"]',vcfg.startFresh).on("click","#publish, #save-post",vcfg.processFormSubmit).on("submit","#post",vcfg.processFormSubmit).on("click",".gv-view-types-hover",vcfg.selectTemplateHover).on("click","a[rel*=external]",vcfg.openExternalLinks).on("click mouseup keyup",vcfg.closeTooltips).on("click",'.gv-field-filter-form span[role="button"]',vcfg.switchTooltipLayout).on("click","#gv_switch_view_button",vcfg.switchView).on("click",".clear-all-fields",vcfg.removeAllFields).on("click",".gv_select_template",vcfg.selectTemplate).on("change","select[data-view-dropdown]",vcfg.selectTemplate).on("click",".ui-tooltip-content .gv-fields",vcfg.startAddField).on("click",".gv-add-field-before",function(){$(this).closest(".active-drop-container").find("a.gv-add-field").trigger("click",{before:$(this).closest(".gv-fields")})}).on("click",".gv-field-duplicate",vcfg.duplicateField).on("click","#gv-direct-access .edit-direct-access",vcfg.editDirectAccess).on("click","#gv-direct-access-select .cancel-direct-access",vcfg.cancelDirectAccess).on("click","#gv-direct-access-select .save-direct-access",vcfg.updateDirectAccess).on("gravityview_form_change",vcfg.updateFormLinks).on("gravityview_form_change",vcfg.updateWidgetFormIds).on("change",".gv-dialog-options input[name*=show_as_link]",vcfg.toggleShowAsEntry).on("change",".gv-dialog-options input[name*=only_loggedin]",vcfg.toggleCustomVisibility).on("change",".gv-dialog-options [name*=allow_edit_cap]",vcfg.toggleCustomVisibility).on("click",".gv-field-controls .gv-remove-field",vcfg.removeField).on("click",".gv-field-controls .gv-field-settings",vcfg.openFieldSettings).on("dblclick",".gv-fields:not(.gv-nonexistent-form-field)",vcfg.openFieldSettings).on("change","#gravityview_settings",vcfg.changedSettingsAction).on("click",".gv-field-details--toggle",function(e){var $dialog=$(this).parents(".ui-dialog"),was_closed=$(".gv-field-details",$dialog).hasClass("gv-field-details--closed");return viewConfiguration.toggleFieldDetails($dialog,was_closed),$.cookie("gv-field-details-expanded",was_closed,{path:gvGlobals.admin_cookiepath}),!1}).on("search keydown keyup",".gv-field-filter-form input:visible",vcfg.setupFieldFilters).on("click",".gv-section .is-dismissible .notice-dismiss",function(e){var warning_name=$(this).parents(".gv-section").attr("id")+"-"+$("#post_ID").val();$.cookie("warning-dismissed-"+warning_name,1,{path:gvGlobals.admin_cookiepath}),$(document.body).trigger("gravityview/tabs-ready")}).on("gravityview/loaded gravityview/tabs-ready gravityview/field-added gravityview/field-removed gravityview/all-fields-removed gravityview/show-as-entry gravityview/view-config-updated",vcfg.toggleTabConfigurationWarnings).on("gravityview/loaded gravityview/tabs-ready gravityview/field-added gravityview/field-removed gravityview/all-fields-removed gravityview/show-as-entry gravityview/view-config-updated",vcfg.toggleRemoveAllFields).on("search keydown keyup",".gv-field-filter-form input:visible",vcfg.setupFieldFilters).on("gravityview/loaded",function(){$(".gv-setting-list, #gravityview_settings").on("change",vcfg.toggleCheckboxes).trigger("change")}).on("change",".gv-dialog-options",vcfg.toggleCheckboxes).on("focus",".gv-add-field",function(e){$(this).parent(".gv-fields").addClass("trigger--hover")}).on("blur",".gv-add-field",function(e){$(this).parent(".gv-fields").removeClass("trigger--hover")}).on("keydown",".gv-add-field",function(e){return 13!==e.keyCode&&32!==e.keyCode||void $(this).parent(".gv-fields").addClass("trigger--active")}).on("keyup",".gv-add-field",function(e){return 13!==e.keyCode&&32!==e.keyCode||void $(this).parent(".gv-fields").removeClass("trigger--active")}).on("gravityview/dropdown/activate gravityview/dropdown/install",vcfg.enableLockedTemplate),$(window).on("resize",function(){var $open_dialog=$(".ui-dialog:visible").find(".ui-dialog-content");$open_dialog.dialog("option","position",{my:"center",at:"center",of:window});var window_width=vcfg.dialogWidth,ninety_five_per=.95*$(window).width();vcfg.dialogWidth>ninety_five_per&&(window_width=ninety_five_per),$open_dialog.dialog("option","width",window_width)}),window.addEventListener("beforeunload",event=>{vcfg.hasUnsavedChanges&&event.preventDefault()}),gvGlobals.passed_form_id&&vcfg.gvSelectForm.trigger("change");var _sendToEditor=window.send_to_editor;window.send_to_editor=function(val){var cursorPosition=$("#"+window.wpActiveEditor);if(!cursorPosition.hasClass("codemirror")&&_sendToEditor)return _sendToEditor(val);var codeMirror=cursorPosition.next(".CodeMirror")[0].CodeMirror,cursorPosition=codeMirror.getCursor();codeMirror.replaceRange(val,window.wp.CodeMirror.Pos(cursorPosition.line,cursorPosition.ch))},$("div .gform-dropdown__trigger").on("click.gravityforms",vcfg.sendMergeTagValueToCodemirrorEditor)},getCookieVal:function(cookie){return!(!cookie||"undefined"===cookie||"false"===cookie)&&cookie},toggleTabConfigurationWarnings:function(e){var tabs={single:{configured:$(".gv-dialog-options input[name*=show_as_link]:checked","#directory-active-fields").length||$('[data-fieldid="entry_link"]',"#directory-active-fields").length,icon:"dashicons-media-default"},edit:{configured:$('.gv-fields .field-key[value="edit_link"]').length,icon:"dashicons-welcome-write-blog"}};$.each(tabs,function(index,value){var show_warning=index+"-fields-"+$("#post_ID").val(),dismissed_warning=viewConfiguration.getCookieVal($.cookie("warning-dismissed-"+show_warning));const $fields_section=$("#"+index+"-fields");show_warning=$fields_section.find(".active-drop .gv-fields").length,show_warning=!dismissed_warning&&0===value.configured&&0",{class:"gv-error-message",text:error}).insertAfter($field))},validateValue(value,rules){if(rules){var i,validators=viewConfiguration.getValidators();for(i in rules)if(rules.hasOwnProperty(i)){var parts=rules[i],rule=parts.rule,message=parts.message,param="",isValid=!0;if(rule.includes(":")&&(rule=(parts=rule.split(/:(.+)/))[0],param=parts[1]),!(isValid=validators[rule]?validators[rule](value,param):isValid))return message}}},getValidators:function(){return{required:function(value){return null!=value&&""!==value.toString().trim()},max:function(value,max){return null!=value&&Number(value)<=max},min:function(value,min){return null!=value&&Number(value)>=min},email:function(value){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)},integer:function(value){return Number.isInteger?Number.isInteger(Number(value)):Number(value)%1==0},matches:function(value,pattern){return new RegExp(pattern).test(value)}}},zebraStripeSettings:function(){jQuery("#gravityview_settings").find("table").each(function(){$trs=$(this).find("tr").not('[style="display: none;"]'),$trs.removeClass("alternate"),$trs.filter(":even").addClass("alternate")})},toggleCheckboxes:function($parent){$parent=$parent.currentTarget||$parent;viewConfiguration.toggleRequired($parent,"requires",!1),viewConfiguration.toggleRequired($parent,"requires-not",!0);$parent=$($parent).is(".gv-fields")?$($parent):$($parent).parents(".gv-fields");$parent.length&&(viewConfiguration.toggleDisabled($("input[type=checkbox][name*=link_to_]",$parent),$("input[type=checkbox][name*=show_as_link]",$parent)),viewConfiguration.toggleDisabled($("input[type=checkbox][name*=link_phone]",$parent),$("input[type=checkbox][name*=show_as_link]",$parent)))},toggleDisabled:function($one,$two){0!==$one.length&&0!==$two.length&&($one.is(":checked")?$two.prop("disabled",!0):$two.is(":checked")&&$one.prop("disabled",!0))},toggleRequired:function(currentTarget,data_attr,reverse_logic){var $parent=$(currentTarget,"#post");$parent.find("[data-"+data_attr+"]").each(function(){var $this=$(this),requires_value=$this.data(data_attr).split("="),$input=requires_value[0],requires_value=requires_value[1],$input=$parent.find('[name$="['+$input+']"]').filter(":input");$input.is("[type=checkbox]")?reverse_logic?$this.toggle(0<$input.filter(":not(:checked)").filter(":not(:hidden)").length):$this.toggle($input.is(":checked")):void 0!==requires_value&&(reverse_logic?$this.toggle($input.val()!==requires_value):$this.toggle($input.val()===requires_value))})},switchTooltipLayout:function(e){var layout=$(this).data("value");viewConfiguration.setTooltipLayout(layout)},setTooltipLayout:function(layout){$(".gv-items-picker--"+layout).addClass("active"),$(".gv-items-picker").not(".gv-items-picker--"+layout).removeClass("active"),$(".gv-items-picker-container").attr("data-layout",layout),$.cookie("gv-items-picker-layout",layout,{path:gvGlobals.admin_cookiepath})},closeTooltips:function(e){var activeTooltips=$("[data-tooltip='active']"),close=!1,return_false=!1;switch(e.type){case"keyup":if(27===e.keyCode){if($(".ui-autocomplete").is(":visible"))return;return_false=close=0===$(".gv-field-filter-form input[data-has-search]:focus").length,window.Beacon&&window.Beacon("close")}((13===e.keyCode||32===e.keyCode)&&$(e.target).is(".close")||$(e.target).is(".dashicons-dismiss"))&&(close=!0);break;case"mouseup":$(e.target).parents(".ui-dialog,.ui-tooltip").length||$(e.target).is(".ui-dialog,.ui-tooltip")?close=!1:0vcfg.dialogWidth?vcfg.dialogWidth:$(window).width()-10},open:function(){return $('
').prependTo("#wpwrap"),$(document.body).trigger("gravityview/dialog-opened",thisDialog),vcfg.toggleCheckboxes(thisDialog),vcfg.setupFieldDetails(thisDialog),vcfg.refresh_merge_tags(thisDialog,function(){vcfg.setupCodeMirror(thisDialog)}),$sortableEls=$('.ui-widget-content[aria-hidden="false"]').find(".active-drop-widget, .active-drop-field"),$sortableEls.length&&$sortableEls.each((i,el)=>{$(el).hasClass("ui-sortable")&&$(el).sortable("disable")}),!0},close:function(e){e.preventDefault(),$("textarea.code",thisDialog).each(function(){$CodeMirror=$(this).next(".CodeMirror"),0!==$CodeMirror.length&&$CodeMirror[0].hasOwnProperty("CodeMirror")&&$CodeMirror[0].CodeMirror.toTextArea()}),thisDialog.find(".merge-tag-support").removeClass("merge-tag-support").addClass("gv-merge-tag-support"),$(".gv-field-settings.active","#gravityview_view_config").removeClass("active"),vcfg.setCustomLabel(thisDialog),$("#wpwrap").find("> .gv-overlay").fadeOut("fast",function(){$(this).remove()}),$sortableEls=$('.ui-widget-content[aria-hidden="false"]').find(".active-drop-widget, .active-drop-field"),$sortableEls.length&&$sortableEls.each((i,el)=>{$(el).hasClass("ui-sortable")&&$(el).sortable("enable")}),vcfg._restoreValue(),$(document.body).trigger("gravityview/dialog-closed",thisDialog)},closeOnEscape:!0,buttons:buttons})},setupCodeMirror:function(dialog){var vcfg=viewConfiguration;$("textarea.code:visible",dialog).each(function(){const codemirrorConfig=$.extend(!0,{},wp.codeEditor.defaultSettings);var $textarea,editorId,mergeTag,initialEditorCursorPos,$autocompleteEl,closeAutocompletion,mergeTags=$(this).data("codemirror");mergeTags&&(codemirrorConfig.codemirror=$.extend({},codemirrorConfig.codemirror,mergeTags));let editor=wp.codeEditor.initialize($(this),codemirrorConfig);($(this).hasClass("merge-tag-support")||$(this).hasClass("gv-merge-tag-support"))&&(editor.codemirror.setSize("95%"),$textarea=$(this),editorId=$textarea.attr("id"),mergeTags=window.gfMergeTags.getAutoCompleteMergeTags($textarea),mergeTag="",initialEditorCursorPos=editor.codemirror.getCursor(),$textarea.parent().find(".all-merge-tags").detach().insertBefore($textarea),$textarea.parent().find("div .gform-dropdown__trigger").on("click.gravityforms",vcfg.sendMergeTagValueToCodemirrorEditor),$textarea.autocomplete({appendTo:$textarea.parent(),minLength:1,position:{my:"center top",at:"center bottom",collision:"none"},source:mergeTags,select:function(event,currentEditorCursorPos){var val=currentEditorCursorPos.item.value.replace(/^{|}$/gm,""),currentEditorCursorPos=editor.codemirror.getCursor();editor.codemirror.replaceRange(val,initialEditorCursorPos,window.wp.CodeMirror.Pos(currentEditorCursorPos.line,currentEditorCursorPos.ch)),editor.codemirror.focus(),editor.codemirror.setCursor(window.wp.CodeMirror.Pos(currentEditorCursorPos.line,currentEditorCursorPos.ch+val.length+1))}}),$autocompleteEl=$textarea.parent().find("ul.ui-autocomplete"),closeAutocompletion=function(){$("#"+editorId).autocomplete("close")},$(document.body).on("keyup",function(e){$autocompleteEl.is(":visible")&&27===e.which&&(e.preventDefault(),closeAutocompletion(),$textarea.focus())}),editor.codemirror.on("mousedown",function(){closeAutocompletion()}),editor.codemirror.on("keydown",function(el,e){$autocompleteEl.is(":visible")&&(38!==e.which&&40!==e.which&&13!==e.which||($autocompleteEl.not(":focus")&&$autocompleteEl.focus(),e.preventDefault()))}),editor.codemirror.on("change",function(e,currentEditorCursorPos){"{}"===currentEditorCursorPos.text[0]&&(initialEditorCursorPos=editor.codemirror.getCursor());currentEditorCursorPos=editor.codemirror.getCursor();"{"!==(mergeTag=editor.codemirror.getRange({ch:initialEditorCursorPos.ch-1,line:initialEditorCursorPos.line},currentEditorCursorPos))[0]?closeAutocompletion():$("#"+editorId).autocomplete("search",mergeTag)}))})},sendMergeTagValueToCodemirrorEditor:function(e){var _activeEditorBackup=window.wpActiveEditor;window.wpActiveEditor=$(e.currentTarget).parentsUntil(".gv-setting-container").find("textarea").attr("id"),window.wpActiveEditor&&window.send_to_editor($(this).data("value")),window.wpActiveEditor=_activeEditorBackup},setupFieldDetails:function(dialog){$(".gv-field-details--container",dialog).insertAfter(".ui-dialog-title:visible");var show_details=$.cookie("gv-field-details-expanded"),show_details=viewConfiguration.getCookieVal(show_details);viewConfiguration.toggleFieldDetails(dialog,show_details),viewConfiguration.migrateSurveyScore(dialog)},migrateSurveyScore:function($dialog){var $score;0===$dialog.parents('[data-inputtype="survey"]').length||($score=$dialog.find(".gv-setting-container-score input"))&&0!=+$score.val()&&$dialog.find('.gv-setting-container-choice_display input[value="score"]').trigger("click").trigger("focus")},toggleFieldDetails:function($dialog,show_details){$parent=$dialog.parent(),$parent.find(".gv-field-details").toggleClass("gv-field-details--closed",!show_details).end().find(".gv-field-details--toggle .dashicons").toggleClass("dashicons-arrow-down",!!show_details).toggleClass("dashicons-arrow-right",!show_details).end()},setCustomLabel:function($label){var custom_label_text=$("[name*=admin_label]",$label),custom_label_text=custom_label_text.length&&custom_label_text.val()?custom_label_text:$("[name*=custom_label]",$label),$label=$label.parents(".gv-fields").find(".gv-field-label-text-container");custom_label_text.length&&(0<(custom_label_text=custom_label_text.val().trim()).length?$label.html(custom_label_text):$label.html($label.attr("data-original-title")))},getSortableFields:function(context,id){return new Promise((resolve,reject)=>{var vcfg=viewConfiguration;$(".gravityview_sort_field").prop("disabled","disabled").empty().append("");var data={action:"gv_sortable_fields_form",nonce:gvGlobals.nonce};void 0!==context&&"preset"===context?data.template_id=id:data.form_id=vcfg.gvSelectForm.val(),$.post(ajaxurl,data,function(response){"false"!==response&&"0"!==response&&$(".gravityview_sort_field").empty().append(response).prop("disabled",null),resolve()})})},hideViewConfig:function(){$("#gravityview_view_config").slideUp(150),$(document).trigger("gv_admin_views_hideViewConfig")},showViewConfig:function(){$("#gravityview_view_config").slideDown(150),viewGeneralSettings.metaboxObj.show(),viewConfiguration.toggleDropMessage(),viewConfiguration.init_tooltips(),$(document).trigger("gv_admin_views_showViewConfig")},switchView:function(vcfg){vcfg.preventDefault(),vcfg.stopImmediatePropagation();vcfg=viewConfiguration;vcfg.templateFilter("custom"),vcfg.toggleViewTypeMetabox()},templateFilter:function(templateType){$(".gv-view-types-module").each(function(){$(this).attr("data-filter")===templateType?$(this).parent().show():$(this).parent().hide()})},_isViewDropDown:function(){return viewConfiguration.wantedTemplate&&void 0!==viewConfiguration.wantedTemplate.data("view-data")},_getCurrentTemplateId(){var section=this._getTemplateSection();return null===section||"directory"===section?this.currentDirectoryTemplate:"single"===section?this.currentSingletemplate:""},_setCurrentTemplateId(template_id){var section=this._getTemplateSection();null!==section&&"directory"!==section||(this.currentDirectoryTemplate=template_id),null!==section&&"single"!==section||(this.currentSingletemplate=template_id)},_getTemplateId:function(use_base_template=!1){const $template=viewConfiguration.wantedTemplate;if(!$template)return"";let template_id=$template.data(use_base_template?"base-template":"templateid");return viewConfiguration._isViewDropDown()&&(template_id=viewConfiguration.wantedTemplate.val(),template_id=String($template.val())),template_id},_getTemplateSection:function(){let section=null;return viewConfiguration._isViewDropDown()&&(section=viewConfiguration.wantedTemplate.data("section")),section},_restoreValue:function(){viewConfiguration._isViewDropDown()&&viewConfiguration.wantedTemplate.data("view-data").restoreValue()},_storeValue:function(){viewConfiguration.wantedTemplate&&(viewConfiguration._isViewDropDown()?viewConfiguration.wantedTemplate.data("view-data").storeValue():$("select[data-view-dropdown]").each(function(){$(this).data("view-data").storeValue()}),this._setCurrentTemplateId(this._getTemplateId()))},selectTemplate:function(slugmatch,currentTemplate){var selectedTemplateId,regexMatch,vcfg=viewConfiguration;void 0!==currentTemplate&&null===currentTemplate.section||(slugmatch.preventDefault(),slugmatch.stopImmediatePropagation(),vcfg.wantedTemplate=$(this),selectedTemplateId=vcfg._getTemplateId(),regexMatch=/(.*?)_(.*?)$/i,slugmatch=(currentTemplate=vcfg._getCurrentTemplateId()).replace(regexMatch,"$2"),slugmatch=selectedTemplateId.replace(regexMatch,"$2")===slugmatch,currentTemplate&&!slugmatch&&vcfg.getConfiguredFields().length?currentTemplate!==selectedTemplateId?vcfg.getConfiguredFields().length?vcfg.showDialog("#gravityview_switch_template_dialog"):(vcfg.toggleViewTypeMetabox(),vcfg.selectTemplateContinue(slugmatch)):(vcfg.toggleViewTypeMetabox(),vcfg.showViewConfig()):($("#gravityview_select_template").slideUp(150),vcfg.selectTemplateContinue(slugmatch),vcfg._storeValue()))},selectTemplateContinue:function(slugmatch){var vcfg=viewConfiguration,selectedTemplateId=vcfg._getTemplateId(),selectedFormId=vcfg.gvSelectForm.val(),changeAllSection=!vcfg._getTemplateSection();changeAllSection&&($parent=vcfg._getTemplateId(),$("#gravityview_directory_template").val($parent).trigger("change",{section:null}),$("#gravityview_single_template").val($parent).trigger("change",{section:null}));var $parent=vcfg.wantedTemplate.parents(".gv-view-types-module");$parent.parents(".gv-grid").find(".gv-view-types-module").removeClass("gv-selected"),$parent.addClass("gv-selected"),vcfg.waiting("start"),vcfg.startFreshStatus?Promise.all([vcfg.getAvailableFields("preset",selectedTemplateId),vcfg.getPresetFields(selectedTemplateId),vcfg.getSortableFields("preset",selectedTemplateId)]).then(function(){$(".ui-tabs-panel").each(function(){vcfg.init_droppables(this)})}):(!slugmatch||changeAllSection?vcfg.updateActiveAreas(selectedTemplateId,+selectedFormId):vcfg.waiting("stop"),changeAllSection&&(vcfg.gvSwitchView.fadeIn(150),vcfg.toggleViewTypeMetabox())),vcfg.currentTemplateId=selectedTemplateId,vcfg.setUnsavedChanges(!0)},server_request:(ajaxRoute,payload)=>{const defer=$.Deferred();viewConfiguration.performingAjaxAction=!0,$(".gv-view-template-notice").hide();var{_wpNonce:nonce,_wpAjaxAction:action,_wpAjaxUrl:url,ajaxRouter,frontendFoundationVersion}=window.gvGlobals.foundation_licenses_router;return $.post(url,{nonce:nonce,action:action,ajaxRouter:ajaxRouter,ajaxRoute:ajaxRoute,frontendFoundationVersion:frontendFoundationVersion,payload:payload}).fail(response=>defer.reject(response.responseText)).done(response=>{response.success?(viewConfiguration.performingAjaxAction=!1,defer.resolve(response)):defer.reject(response.data)}),defer.promise()},selectTemplateHover:function(on_success){const vcfg=viewConfiguration,$link=$(on_success.target),$parent=$link.parents(".gv-view-types-module"),$select=$(this).find(".gv_select_template");if($link.is("[rel=internal]")&&!$link.hasClass("gv-layout-activate")&&!$link.hasClass("gv-layout-install"))return!0;on_success.preventDefault(),on_success.stopImmediatePropagation();var on_fail=error=>{$(".gv-view-template-notice").show().find("p").html(error),document.querySelector(".gv-view-template-notice").scrollIntoView({behavior:"smooth"})},do_always=()=>{vcfg.performingAjaxAction=!1,$link.removeClass("disabled"),$parent.removeClass("active")},on_success=()=>{$parent.find(".gv-view-types-hover > div:eq(0)").hide(),$parent.find(".gv-view-types-hover > div:eq(1)").removeClass("hidden"),$parent.removeClass("gv-view-template-placeholder"),$parent.find("a.gv_select_template").attr("data-templateid",$link.data("templateid")).trigger("click"),vcfg.activateViewSelection($link.data("templateid")),$select.trigger("click")};if($link.hasClass("gv-layout-activate"))return vcfg.performingAjaxAction?void 0:($parent.addClass("active"),$link.addClass("disabled").attr("disabled",!0),$link.html($spinner),void $.when(vcfg.server_request("activate_product",{text_domain:$link.attr("data-template-text-domain")})).then(on_success).always(do_always).fail(on_fail));$link.hasClass("gv-layout-install")&&(vcfg.performingAjaxAction||($parent.addClass("active"),$link.addClass("disabled").attr("disabled",!0),$link.html($spinner),$.when(vcfg.server_request("install_product",{id:$link.attr("data-download-id"),text_domain:$link.attr("data-template-text-domain"),activate:!0})).then(on_success).always(do_always).fail(on_fail)))},enableLockedTemplate:function(e,data){const $option=$(data?.option)||null;var action=data?.action||null,payload={text_domain:$option.data("template-text-domain"),activate:!0};if("{}"!==JSON.stringify(payload)){const $pill=$(e.target),$item=$pill.closest(".view-dropdown-list-item");$pill.addClass("is-idle").html($spinner),$item.addClass("is-idle"),$.when(viewConfiguration.server_request(action+"_product",payload)).then(()=>{$pill.removeClass("has-failed"),viewConfiguration.activateViewSelection($option.data("template-id")),data?.dropdown?.focusActive()}).fail(error=>{$pill.addClass("has-failed").text("Error"),console.log(error)}).always(()=>{$pill.removeClass("is-idle"),$item.removeClass("is-idle")})}},activateViewSelection:function(template_id){const $view_selectors=$("[data-view-dropdown]"),$options=$view_selectors.find('option[data-template-id="'+template_id+'"]');$options.attr("disabled",!1),$options.val(template_id),$view_selectors.each((_,el)=>{const dropdown=$(el).viewDropdown();dropdown.renderOptions()}),viewConfiguration.updateSettingsArea()},openExternalLinks:function(){return window.Beacon&&($(this).is("[data-beacon-article]")||$(this).is("[data-beacon-article-modal]")||$(this).is("[data-beacon-article-sidebar]")||$(this).is("[data-beacon-article-inline]"))||window.open(this.href),!1},previewTemplate:function(e){e.preventDefault(),e.stopImmediatePropagation();var parent=$(e.currentTarget).parents(".gv-view-types-module");parent.find(".gv-template-preview").dialog({dialogClass:"wp-dialog gv-dialog",appendTo:$("#gravityview_select_template"),width:viewConfiguration.dialogWidth,open:function(){$('
').prependTo("#wpwrap")},close:function(){$(this).dialog("option","appendTo",parent),$("#wpwrap").find("> .gv-overlay").fadeOut("fast",function(){$(this).remove()})},closeOnEscape:!0,buttons:[{text:gvGlobals.label_close,click:function(){$(this).dialog("close")}}]})},updateActiveAreas:function(template,data){var vcfg=viewConfiguration,data={action:"gv_get_active_areas",template_id:template,form_id:data,nonce:gvGlobals.nonce};return vcfg.updateViewConfig(data)},updateSettingsArea:function(){const $settings_content=$("#gravityview_settings .inside");$settings_content.html(""),$.get(document.URL,function(response){if(response){const $document=$(response);$settings_content.html($document.find("#gravityview_settings .inside").html()),viewGeneralSettings.refresh(),$("#gravityview_directory_template").trigger("change")}})},getPresetFields:function(data){var vcfg=viewConfiguration;$("#directory-active-fields, #single-active-fields").children().remove();data={action:"gv_get_preset_fields",template_id:data,nonce:gvGlobals.nonce};return vcfg.updateViewConfig(data)},updateViewConfig:function(data){return new Promise((resolve,reject)=>{const vcfg=viewConfiguration,section=vcfg._getTemplateSection(),update_directory="directory"===section||null===section,update_single="single"===section||null===section;update_directory&&$("#directory-active-fields").children().remove(),update_single&&$("#single-active-fields").children().remove(),$.post(ajaxurl,data,function(content){content&&(content=JSON.parse(content),update_directory&&($("#directory-header-widgets").html(content.header),$("#directory-footer-widgets").html(content.footer),$("#directory-active-fields").append(content.directory),$("#directory-header-widgets a[data-templateid], #directory-footer-widgets a[data-templateid]").attr("data-templateid",data.template_id).attr("data-formid",data.form_id)),update_single&&$("#single-active-fields").append(content.single),vcfg.showViewConfig(),vcfg.waiting("stop"),$(document.body).trigger("gravityview/view-config-updated",content,section)),resolve()}),vcfg.setUnsavedChanges(!0)})},waiting:function(action){$containers=$("#wpwrap,.gv-fields"),"start"===action?$containers.addClass("gv-wait"):$containers.removeClass("gv-wait")},remove_tooltips:function(el){$(el||".gv-add-field").is(":ui-tooltip")&&$(".gv-add-field").gvTooltip("destroy").off("click")},init_tooltips:function(el){0!==$(el||".gv-add-field","#post").not(":ui-tooltip").length&&$(el||".gv-add-field","#post").gvTooltip({show:150,hide:200,content:function(){var context=$(this).attr("data-context"),formId=$(this).attr("data-formid")||$("#gravityview_form_id").val(),templateId=$("#gravityview_directory_template").val();switch($(this).attr("data-objecttype")){case"field":return $("#"+context+"-available-fields-"+(formId||templateId)).html();case"widget":return $("#directory-available-widgets").html()}},close:function(){$(this).attr("data-tooltip",null)},open:function(event,tooltip){$(this).attr("data-tooltip","active").attr("data-tooltip-id",$(this).attr("aria-describedby")),$focus_item=$("input[type=search]",tooltip.tooltip),$focus_item.length||($focus_item=$(tooltip.tooltip).find(".close").first());var box="list";$(tooltip).find(".gv-items-picker-container[data-layout]").length?box=$(tooltip).find(".gv-items-picker-container[data-layout]").attr("data-layout"):(layout_cookie=$.cookie("gv-items-picker-layout"),viewConfiguration.getCookieVal(layout_cookie)&&(box=layout_cookie)),viewConfiguration.setTooltipLayout(box),$focus_item[0].focus({preventScroll:!0});box=$focus_item[0].getBoundingClientRect();(box.y<0||box.y>document.body.getBoundingClientRect().height)&&window.scrollTo({left:window.scrollX,top:window.scrollY+box.y+(box.y<0?-60:60),behavior:"smooth"})},closeOnEscape:!0,disabled:!0,position:{my:"center bottom",at:"center top-12"},tooltipClass:"gravityview-item-picker-tooltip top"}).attr("title",function(){return $(this).attr("title")||$(this).data("title")||""}).on("mouseout focusout",e=>e.stopImmediatePropagation()).on("click",function(e,data){$(this).attr("title",""),$(this).data("before",null),data?.before&&$(this).data("before",data.before),e.preventDefault(),$(this).gvTooltip("open")})},setupFieldFilters:function(e){var input=$(this).val().trim(),$tooltip=$(this).parents(".ui-tooltip-content"),$resultsNotFound=$tooltip.find(".gv-no-results");"keydown"!==e.type?($tooltip.find(".gv-fields").show().filter(function(){var match_title=$(this).find(".gv-field-label").attr("data-original-title").match(new RegExp(input,"i")),match_id=$(this).attr("data-fieldid").match(new RegExp(input,"i")),match_parent=!!$(this).attr("data-parent-label")&&$(this).attr("data-parent-label").match(new RegExp(input,"i"));return!match_title&&!match_id&&!match_parent}).hide(),$tooltip.find(".gv-fields:visible").length?$resultsNotFound.hide():$resultsNotFound.show()):$(this).attr("data-has-search",0{var vcfg=viewConfiguration;vcfg.toggleDropMessage(),vcfg.getConfiguredFields().remove();var data={action:"gv_available_fields",nonce:gvGlobals.nonce};data.form_preset_ids=void 0!==preset&&"preset"===preset?[templateid]:[vcfg.gvSelectForm.val()],$("#directory-available-fields-"+data.form_preset_ids[0]).length||$.post(ajaxurl,data,function(response){response.success||response.data||resolve(),$.each(response.data,function(context,markup){$("#"+context+"-fields").append(markup)}),resolve()})})},startAddField:function(e){$(this).has(".field-id-all-fields").length?viewConfiguration.addAllFields($(this)):viewConfiguration.addField($(this),e)},addAllFields:function(clicked){const fields=clicked.siblings(".gv-fields").filter(function(){var field_id=$(this).data("fieldid");return+field_id===parseInt(field_id,10)});!async function(){for(let i=0;inew Promise((resolve,reject)=>{$(document.body).one("gravityview/field-added",function(){resolve()}),$(el).trigger("click")}))(fields[i]);$("a.gv-add-field[data-tooltip='active']").gvTooltip("close")}()},addField:function(clicked,$before){$before.preventDefault();$before=clicked.closest(".ui-tooltip").attr("id");const $addButton=$('.gv-add-field[data-tooltip-id="'+$before+'"]');$before=$addButton.data("before");viewConfiguration.placeField(clicked,$addButton,$before,!!$before)},placeField:function($field,$addButton,$anchor,add_before_anchor=!1){const vcfg=viewConfiguration,$newField=$field.clone().hide();var data={action:"gv_field_options",template:$addButton.attr("data-templateid")??$addButton.parents(".gv-section").find(".view-template-select select").val()??$("#gravityview_directory_template").val(),area:$addButton.attr("data-areaid"),context:$addButton.attr("data-context"),field_id:$newField.attr("data-fieldid"),field_label:$newField.find(".gv-field-label").attr("data-original-title"),field_type:$addButton.attr("data-objecttype"),input_type:$newField.attr("data-inputtype"),form_id:parseInt($field.attr("data-formid"),10)||vcfg.currentFormId,nonce:gvGlobals.nonce};$.ajax({type:"POST",url:ajaxurl,data:data,async:!0,beforeSend:function(){vcfg.disable_publish()},complete:function(){vcfg.enable_publish()}}).done(function(response){var insert_method=/[^\[]+\[[^\]]+\]\[([^\]]+)\].*/i;if(0<$field.find("input.field-key").length){$newField.find(".gv-dialog, .gv-dialog-options").remove();const oldId=$field.find("input.field-key").attr("name").replace(insert_method,"$1"),newId=response.match(insert_method,"$1")[1]??null;response=$(response),$field.find(".gv-dialog-options :input").each(function(i,el){if($(el).attr("name")){const $fields=response.find('[name="'+$(el).attr("name").replaceAll(""+oldId,""+newId)+'"]');1===$fields.length?$fields.val($(el).val()):2===$fields.length&&$(el).is(":checked")&&$fields.prop("checked",!0)}})}$newField.append(response),$(".ui-tabs-panel").each(function(){vcfg.init_droppables(this)}),0<$(".gv-dialog-options",$newField).length&&$(".gv-field-settings",$newField).removeClass("hide-if-js"),$anchor?(insert_method=add_before_anchor?"insertBefore":"insertAfter",$newField[insert_method]($anchor)):$addButton.closest(".gv-droppable-area").find(".active-drop").append($newField),$(document.body).trigger("gravityview/field-added",$newField),$newField.fadeIn(100),vcfg.refreshGFtooltips()}).fail(function(jqXHR){vcfg.enable_publish(),alert(gvGlobals.field_loaderror),console.log(jqXHR)}).always(function(){vcfg.toggleDropMessage(),vcfg.setUnsavedChanges(!0)})},duplicateField:function($field){$field.preventDefault();$field=$(this).closest(".gv-fields");viewConfiguration.placeField($field,$(this).closest(".active-drop-container").find("a.gv-add-field"),$field)},refresh_merge_tags:function($source,onRefresh){let $merge_tag_supported=$source?$(".gv-merge-tag-support,.merge-tag-support",$source):$(".gv-merge-tag-support:visible");if($merge_tag_supported.removeClass("gv-merge-tag-support mt-initialized").addClass("merge-tag-support"),window.gform?.instances?.mergeTags)return $(".all-merge-tags",$source).remove(),document.dispatchEvent(new Event("DOMContentLoaded")),void setTimeout(function(){$merge_tag_supported.removeClass("merge-tag-support").addClass("gv-merge-tag-support"),onRefresh&&onRefresh()},300);"undefined"!=typeof form&&$(document.body).not(".gv-form-changed")&&0<=$merge_tag_supported.length&&(window.gfMergeTags&&($(".all-merge-tags:visible").remove(),gfMergeTags.hasOwnProperty("destroy")?$merge_tag_supported.each(function(){new gfMergeTagsObj(form,$(this))}):window.gfMergeTags=new gfMergeTagsObj(form)),$merge_tag_supported.removeClass("merge-tag-support").addClass("gv-merge-tag-support"),onRefresh&&onRefresh())},enable_publish:function(){$(document).trigger("autosave-enable-buttons.edit-post"),$("#publishing-action").find("#publish").prop("disabled",null).removeClass("button-primary-disabled")},disable_publish:function(){$(document).trigger("autosave-disable-buttons.edit-post"),$("#publishing-action").find("#publish").prop("disabled","disabled").addClass("button-primary-disabled")},init_droppables:function(panel){var vcfg;$(panel).find(".active-drop-field").sortable("instance")||(vcfg=viewConfiguration,$(panel).find(".active-drop-widget").sortable({placeholder:"fields-placeholder",items:"> .gv-fields",distance:2,revert:75,connectWith:".active-drop-widget",start:function(event,ui){$("#directory-fields, #single-fields").find(".active-drop-container-widget").addClass("is-receivable")},stop:function(event,ui){$("#directory-fields, #single-fields").find(".active-drop-container-widget").removeClass("is-receivable")},change:function(event,ui){vcfg.setUnsavedChanges(!0)},receive:function(event,ui){var sender_area=ui.sender.attr("data-areaid"),receiver_area=$(this).attr("data-areaid");ui.item.find('[name^="widgets['+sender_area+']"]').each(function(){var name=$(this).attr("name");$(this).attr("name",name.replace(sender_area,receiver_area))}),vcfg.toggleDropMessage()}}),$(panel).find(".active-drop-field").sortable({placeholder:"fields-placeholder",items:"> .gv-fields",distance:2,revert:75,connectWith:".active-drop-field",start:function(event,ui){$(panel).find(".active-drop-container-field").addClass("is-receivable")},stop:function(event,ui){$(panel).find(".active-drop-container-field").removeClass("is-receivable")},change:function(event,ui){vcfg.setUnsavedChanges(!0)},receive:function(event,ui){var sender_area,receiver_area;0",{name:"gv_fields",value:serialized_data,type:"hidden"})),setTimeout(function(){$post.data("gv-valid",!0),"click"===e.type?$(e.target).trigger("click"):$post.trigger("submit")},101),!1)},createPresetForm:function(e,data){var vcfg=viewConfiguration,$target=$(e.target);e.stopPropagation();data={action:"gv_set_preset_form",template_id:data,nonce:gvGlobals.nonce};return $.ajax({type:"POST",url:ajaxurl,data:data,async:!1,success:function(response){"false"!==response&&"0"!==response?(vcfg.startFreshStatus=!1,vcfg.gvSelectForm.find("option:selected").removeAttr("selected").end().append(response),"click"===e.type?$target.trigger("click"):$("#post").trigger("submit")):$target.before('

'+gvGlobals.label_publisherror+"

")}}),!1}},viewGeneralSettings={templateId:null,metaboxObj:null,init:function(){viewGeneralSettings.metaboxObj=$("#gravityview_settings"),viewGeneralSettings.initTabs(),$("#gravityview_directory_template").on("change",viewGeneralSettings.updateSettingsDisplay),$(document.body).on("gravityview/settings/tab/enable",viewGeneralSettings.enableSettingTab).on("gravityview/settings/tab/disable",viewGeneralSettings.disableSettingTab)},refresh:function(){viewGeneralSettings.metaboxObj.trigger("change"),viewGeneralSettings.metaboxObj.tabs("destroy"),viewGeneralSettings.initTabs()},updateSettingsDisplay:function(){viewGeneralSettings.templateId=$(this).val(),$("tr[data-show-if]").each(viewGeneralSettings.toggleSetting)},toggleSetting:function(){var row=$(this),templates=row.attr("data-show-if");templates.length<1||!viewGeneralSettings.templateId||(0');$(document).on("click",".gk-gravityview-placeholder-actions [data-action]",function(payload){var action;payload.preventDefault(),viewConfiguration.hasUnsavedChanges&&!window.confirm(gvGlobals.discard_unsaved_changes)||$(this).hasClass("is-idle")||($(this).addClass("is-idle").html($spinner),action=$(this).data("action")+"_product",payload={text_domain:$(this).data("text-domain"),activate:!0},$.when(viewConfiguration.server_request(action,payload)).then(response=>{if(!response.success)throw new Error;document.location=document.location}).fail(()=>$(this).removeClass("is-idle").addClass("is-error").text("Try again")))})})}(jQuery); \ No newline at end of file