You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
123 KiB
JavaScript
21 lines
123 KiB
JavaScript
7 months ago
|
var WPFormsBuilder=window.WPFormsBuilder||function(r,l,b){var m,v,y={},i=!0,a=!1,k={settings:{spinner:'<i class="wpforms-loading-spinner"></i>',spinnerInline:'<i class="wpforms-loading-spinner wpforms-loading-inline"></i>',tinymceDefaults:{tinymce:{toolbar1:"bold,italic,underline,blockquote,strikethrough,bullist,numlist,alignleft,aligncenter,alignright,undo,redo,link"},quicktags:!0},pagebreakTop:!1,pagebreakBottom:!1,upload_img_modal:!1},init:function(){var e=this;wpforms_panel_switch=!0,m=this.settings,b(k.ready),b(l).on("load",function(){"function"==typeof b.ready.then?b.ready.then(k.load):k.load()}),b(l).on("beforeunload",function(){if(!e.formIsSaved()&&i)return wpforms_builder.are_you_sure_to_close})},load:function(){if(wpf.getQueryString("newform")&&k.formSave(!1),"revisions"===b("#wpforms-panels-toggle .active").data("panel")&&k.updateRevisionPreview(),WPFormsUtils.triggerEvent(v,"wpformsBuilderReady").isDefaultPrevented())return!1;k.hideLoadingOverlay(),"1"==wpforms_builder.template_modal_display&&"fields"===wpf.getQueryString("view")&&b.alert({title:wpforms_builder.template_modal_title,content:wpforms_builder.template_modal_msg,icon:"fa fa-info-circle",type:"blue",buttons:{confirm:{text:wpforms_builder.close,btnClass:"btn-confirm",keys:["enter"]}}})},ready:function(){k.isVisitedViaBackButton()?location.reload():(v=b("#wpforms-builder"),y.$helpButton=b("#wpforms-help"),y.$previewButton=b("#wpforms-preview-btn"),y.$embedButton=b("#wpforms-embed"),y.$saveButton=b("#wpforms-save"),y.$exitButton=b("#wpforms-exit"),y.$noFieldsOptions=b("#wpforms-panel-fields .wpforms-no-fields-holder .no-fields"),y.$noFieldsPreview=b("#wpforms-panel-fields .wpforms-no-fields-holder .no-fields-preview"),y.$formPreview=b("#wpforms-panel-fields .wpforms-preview-wrap"),y.$revisionPreview=b("#wpforms-panel-revisions .wpforms-panel-content"),y.defaultEmailSelector=".wpforms-field-option-email .wpforms-field-option-row-default_value input",y.$defaultEmail=b(y.defaultEmailSelector),y.$focusOutTarget=null,y.$nextFieldId=b("#wpforms-field-id"),y.$fieldOptions=b("#wpforms-field-options"),y.$fieldsPreviewWrap=b("#wpforms-panel-fields .wpforms-panel-content-wrap"),y.$sortableFieldsWrap=b("#wpforms-panel-fields .wpforms-field-wrap"),y.$addFieldsButtons=b(".wpforms-add-fields-button").not(".not-draggable").not(".warning-modal").not(".education-modal"),y.$fieldsSidebar=b("#wpforms-panel-fields .wpforms-add-fields"),y.$searchInput=b("#wpforms-search-fields-input"),y.$sidebarToggle=b(".wpforms-panels .wpforms-panel-sidebar-content .wpforms-panel-sidebar-toggle"),k.isBuilderInPopup()&&(y.$embedButton.remove(),y.$previewButton.addClass("wpforms-alone")),k.loadMsWinCSS(),k.bindUIActions(),m.formID=b("#wpforms-builder-form").data("id"),m.pagebreakTop=b(".wpforms-pagebreak-top").length,m.pagebreakBottom=b(".wpforms-pagebreak-bottom").length,v.on("keypress","#wpforms-builder-form :input:not(textarea)",function(e){13===e.keyCode&&e.preventDefault()}),b(".wpforms-panel").each(function(e,i){var o,t=b(this),r=t.find(".wpforms-panel-sidebar-section.configured").first();r.length?(o=r.data("section"),r.addClass("active"),t.find(".wpforms-panel-content-section-"+o).show().addClass("active"),t.find(".wpforms-panel-content-section-default").hide()):(t.find(".wpforms-panel-content-section:first-of-type").show().addClass("active"),t.find(".wpforms-panel-sidebar-section:first-of-type").addClass("active"))}),k.loadEntryPreviewFields(),k.fieldChoiceSortable("select"),k.fieldChoiceSortable("radio"),k.fieldChoiceSortable("checkbox"),k.fieldChoiceSortable("payment-multiple"),k.fieldChoiceSortable("payment-checkbox"),k.fieldChoiceSortable("payment-select"),b(".wpforms-add-fields-group").each(function(e,i){k.fieldGroupToggle(b(this),"load")}),k.registerTemplates(),k.trimFormTitle(),wpf.initTooltips(),k.loadColorPickers(),k.captchaToggle(),k.confirmationsSetup(),k.notificationToggle(),k.notificationsByStatusAlerts(),k.builderHotkeys(),b("#wpforms-setup-name").val(b("#wpforms-panel-field-settings-form_title").val()),jconfirm.defaults={closeIcon:!1,backgroundDismiss:!1,escapeKey:!
|
||
|
<p class="heading">${wpforms_builder.layout_selector_layout}</p>
|
||
|
<div class="layouts">`;for(t in r){for(var n in e=r[t],i+='<div class="layout-selector-display-layout">',e)i+=`<span class="${e[n].class}" data-classes="${e[n].data}"></span>`;i+="</div>"}i+="</div></div>",b(`#wpforms-field-option-row-${o}-css > label`).after(i)}},fieldLayoutSelectorLayout:function(e){e=b(e);e.parent().find(".layout-selector-display-layout").not(e).remove(),e.parent().find(".heading").text(wpforms_builder.layout_selector_column),e.toggleClass("layout-selector-display-layout layout-selector-display-columns")},fieldLayoutSelectorInsert:function(e){var e=b(e),i=e.closest(".layout-selector-display"),o=i.parent(),t=o.find("label"),o=o.find("input[type=text]"),e=e.data("classes");o.val()&&(e=" "+e),o.insertAtCaret(e),i.slideUp(400,function(){i.remove()}),t.find(".toggle-layout-selector-display").removeClass("layout-selector-showing"),t.find(".toggle-layout-selector-display span").text(wpforms_builder.layout_selector_show)},bindUIActionsSettings:function(){v.on("click","#wpforms-panel-fields .wpforms-title-desc, #wpforms-panel-fields .wpforms-field-submit-button, .wpforms-center-form-name",function(e){e.preventDefault(),k.panelSwitch("settings"),(b(this).hasClass("wpforms-center-form-name")||b(this).hasClass("wpforms-title-desc"))&&setTimeout(function(){b("#wpforms-panel-field-settings-form_title").trigger("focus")},300)}),v.on("click",".wpforms-field-pagebreak-last button",function(e){e.preventDefault(),k.panelSwitch("settings"),b("#wpforms-panel-field-settings-pagebreak_prev").trigger("focus")}),v.on("click",".wpforms-panel-content-also-available-item-add-captcha",function(e){e.preventDefault();e=v.find("#wpforms-add-fields-captcha");e.data("action")?e.trigger("click"):k.fieldAdd("captcha",{}).done(function(){k.panelSwitch("fields")})}),v.on("input","#wpforms-panel-field-settings-pagebreak_prev",function(){b(".wpforms-field-pagebreak-last button").text(b(this).val())}),v.on("input","#wpforms-panel-field-settings-form_title, #wpforms-setup-name",function(){var e=b(this).val().toString().trim();b(".wpforms-preview .wpforms-form-name").text(e),b(".wpforms-center-form-name.wpforms-form-name").text(e),k.trimFormTitle()}),v.on("input","#wpforms-panel-field-settings-form_desc",function(){b(".wpforms-form-desc").text(b(this).val())}),v.on("input","#wpforms-panel-field-settings-submit_text",function(){b(".wpforms-field-submit input[type=submit]").val(b(this).val())}),v.on("change","#wpforms-panel-field-settings-recaptcha",function(){k.captchaToggle()}),v.on("change",".wpforms-panel-field-confirmations-type",function(){k.confirmationFieldsToggle(b(this))}),v.on("change",".wpforms-panel-field-confirmations-message_entry_preview",k.confirmationEntryPreviewToggle),v.on("change","#wpforms-panel-field-settings-notification_enable",function(){k.notificationToggle()}),v.on("click",".wpforms-builder-settings-block-add",function(e){e.preventDefault(),wpforms_builder.pro&&k.settingsBlockAdd(b(this))}),v.on("click",".wpforms-builder-settings-block-edit",function(e){e.preventDefault();e=b(this);e.parents(".wpforms-builder-settings-block-header").find(".wpforms-builder-settings-block-name").hasClass("editing")?k.settingsBlockNameEditingHide(e):k.settingsBlockNameEditingShow(e)}),v.on("blur",".wpforms-builder-settings-block-name-edit input",function(e){b(e.relatedTarget).hasClass("wpforms-builder-settings-block-edit")||k.settingsBlockNameEditingHide(b(this))}),v.on("keypress",".wpforms-builder-settings-block-name-edit input",function(e){13===e.keyCode&&(k.settingsBlockNameEditingHide(b(this)),e.preventDefault())}),v.on("click",".wpforms-builder-settings-block-clone",function(e){e.preventDefault(),k.settingsBlockPanelClone(b(this))}),v.on("click",".wpforms-builder-settings-block-toggle",function(e){e.preventDefault(),k.settingsBlockPanelToggle(b(this))}),v.on("click",".wpforms-builder-settings-block-delete",function(e){e.preventDefault(),k.settingsBlockDelete(b(this))})},captchaToggle:function(){var e=v.find(".wpforms-field-recaptcha"),i=b("#wpforms-panel-field-settings-recaptcha"),o=i.data("provider")||"recaptcha";e.length&&(i
|
||
|
.wpforms-panel-content-section-payment-toggle-recurring input,
|
||
|
#wpforms-panel-field-stripe-enable,
|
||
|
#wpforms-panel-field-paypal_standard-enable,
|
||
|
#wpforms-panel-field-authorize_net-enable,
|
||
|
#wpforms-panel-field-square-enable`},toggleOptionsGroup:function(e){function i(){e.prop("disabled",!1)}var o=e.attr("name"),t=e.attr("type"),r="",o=b('.wpforms-panel-field-toggle-body[data-toggle="'+o+'"]');0===o.length?i():(r="checkbox"!==t&&"radio"!==t||e.prop("checked")?e.val():"0",o.each(function(){var e=b(this);e.attr("data-toggle-value").toString()===r.toString()?e.slideDown("",i):e.slideUp("",i)}))},toggleAllOptionGroups:function(e){(e=e||v||b("#wpforms-builder")||b("body"))&&e.find(".wpforms-panel-field-toggle").each(function(){var e=b(this);e.prop("disabled",!0),k.toggleOptionsGroup(e)})},toggleUnfoldableGroup:function(e){e.preventDefault();var i=b(e.target).closest(".wpforms-panel-fields-group"),e=i.find(".wpforms-panel-fields-group-inner"),o="wpforms_fields_group_"+i.data("group");i.hasClass("opened")?(wpCookies.remove(o),e.stop().slideUp(150,function(){i.removeClass("opened")})):(wpCookies.set(o,"true",2592e3),i.addClass("opened"),e.stop().slideDown(150))},hideFieldHelper:function(e){e.preventDefault(),e.stopPropagation();e=b(".wpforms-field-helper");wpCookies.set("wpforms_field_helper_hide","true",2592e3),e.hide()},smartTagToggle:function(e){e.preventDefault(),y.$focusOutTarget=null;var e=b(this),i=e.closest(".wpforms-panel-field,.wpforms-field-option-row");i.hasClass("smart-tags-toggling")||(i.addClass("smart-tags-toggling"),e.hasClass("smart-tag-showing")?k.removeSmartTagsList(e):k.insertSmartTagsList(e))},removeSmartTagsList:function(e){var i=e.closest(".wpforms-panel-field,.wpforms-field-option-row"),o=i.find(".smart-tags-list-display");e.find("span").text(wpforms_builder.smart_tags_show),o.slideUp("",function(){o.remove(),e.removeClass("smart-tag-showing"),i.removeClass("smart-tags-toggling")})},insertSmartTagsList:function(e){var i,o=e.closest(".wpforms-panel-field,.wpforms-field-option-row"),t=e.closest("label"),r=!0;t.length||(t=o.find("label"),r=!1),i=k.getSmartTagsList(e,-1!==t.attr("for").indexOf("wpforms-field-option-")),(r?t:e).after(i),e.find("span").text(wpforms_builder.smart_tags_hide),o.find(".smart-tags-list-display").slideDown("",function(){e.addClass("smart-tag-showing"),o.removeClass("smart-tags-toggling")})},getSmartTagsList:function(e,i){var o='<ul class="smart-tags-list-display unfoldable-cont">';return(o+=k.getSmartTagsListFieldsElements(e))+k.getSmartTagsListOtherElements(e,i)+"</ul>"},getSmartTagsListFieldsElements:function(e){var i,o=e.data("type"),t=k.getSmartTagsFields(e),r="";if(!["fields","all"].includes(o))return"";if(!t)return'<li class="heading">'+wpforms_builder.fields_unavailable+"</li>";for(i in r+='<li class="heading">'+wpforms_builder.fields_available+"</li>",wpf.orders.fields){var n=wpf.orders.fields[i];t[n]&&(r+=k.getSmartTagsListFieldsElement(t[n]))}return r},getSmartTagsFields:function(e){e=e.data("fields");return e&&e.length?wpf.getFields(e.split(","),!0):wpf.getFields(!1,!0)},getSmartTagsListFieldsElement:function(e){var i=e.label?wpf.encodeHTMLEntities(wpf.sanitizeHTML(e.label)):wpforms_builder.field+" #"+e.id;return'<li><a href="#" data-type="field" data-meta=\''+e.id+"'>"+i+"</a></li>"},getSmartTagsListOtherElements:function(e,i){var o,t,e=e.data("type");if("other"!==e&&"all"!==e)return"";for(t in o='<li class="heading">'+wpforms_builder.other+"</li>",wpforms_builder.smart_tags)i&&-1<wpforms_builder.smart_tags_disabled_for_fields.indexOf(t)||(o+='<li><a href="#" data-type="other" data-meta=\''+t+"'>"+wpforms_builder.smart_tags[t]+"</a></li>");return o},smartTagInsert:function(e){e.preventDefault();var i,e=b(this),o=e.closest(".smart-tags-list-display"),t=o.closest(".wpforms-panel-field,.wpforms-field-option-row"),r=t.find(".toggle-smart-tag-display"),n=t.find("input[type=text], textarea"),s=e.data("meta"),e="field"===e.data("type")?'{field_id="'+s+'"}':"{"+s+"}";"undefined"!=typeof tinyMCE&&(i=tinyMCE.get(n.prop("id")))&&!i.hasFocus()&&i.focus(!0),i&&!i.isHidden()?i.insertContent(e):(n.insertAtCaret(" "+e+" "),n.val(n.val().trim().replace(" "," ")),n.trigger("focus").trigger("input")),o.slideUp("",function(){o.remove()}),r.find("span").text(wpforms_builde
|
||
|
${wpforms_builder.icon_choices.strings.icon_picker_title}
|
||
|
<span class="wpforms-icon-picker-description">${wpforms_builder.icon_choices.strings.icon_picker_description}</span>
|
||
|
<input type="text" placeholder="${wpforms_builder.icon_choices.strings.icon_picker_search_placeholder}" class="search" id="wpforms-icon-picker-search">
|
||
|
`,o=`
|
||
|
<div class="wpforms-icon-picker-container" id="wpforms-icon-picker-icons">
|
||
|
<ul class="wpforms-icon-picker-icons" data-field-id="${i.fieldId}" data-choice-id="${i.choiceId}"></ul>
|
||
|
<ul class="wpforms-icon-picker-pagination"></ul>
|
||
|
<p class="wpforms-icon-picker-not-found wpforms-hidden" data-message="${wpforms_builder.icon_choices.strings.icon_picker_not_found}"></>
|
||
|
</div>`;b.confirm({title:e,titleClass:"wpforms-icon-picker-title",content:o,icon:!1,closeIcon:!0,type:"orange",backgroundDismiss:!0,boxWidth:800,contentMaxHeight:368,smoothContent:!1,buttons:!1,onOpenBefore:function(){this.$body.addClass("wpforms-icon-picker-jconfirm-box"),this.$contentPane.addClass("wpforms-icon-picker-jconfirm-content-pane")},onContentReady:function(){const e=this;k.iconChoices.initIconsList(i),e.$title.find(".search").focus(),e.$content.find(".wpforms-icon-picker-icons").on("click","li",function(){k.iconChoices.selectIcon(e,b(this))})}})},initIconsList:function(o){var e={valueNames:["name"],listClass:"wpforms-icon-picker-icons",page:wpforms_builder.icon_choices.icons_per_page,pagination:{paginationClass:"wpforms-icon-picker-pagination"},item:function(e){var i=e.icon===o.selectedIcon&&e.style===o.selectedIconStyle?'class="selected"':"";return`
|
||
|
<li data-icon="${e.icon}" data-icon-style="${e.style}"${i}>
|
||
|
<i class="ic-fa-${e.style} ic-fa-${e.icon}"></i>
|
||
|
<span class="name">${e.icon}</span>
|
||
|
</li>`},indexAsync:!0};const t=new List("wpforms-icon-picker-icons",e,wpforms_builder.icon_choices.icons);k.iconChoices.infiniteScrollPagination(t),b("#wpforms-icon-picker-search").on("keyup",function(){t.search(b(this).val(),["name"],function(o,e){for(let e=0,i=t.items.length;e<i;e++)t.items[e].found=new RegExp(o).test(t.items[e].values().icon)})}),t.on("searchComplete",function(){var e=b(".wpforms-icon-picker-not-found");e.html(e.data("message").replace("{keyword}",b("#wpforms-icon-picker-search").val())),e.toggleClass("wpforms-hidden",!_.isEmpty(t.matchingItems))})},infiniteScrollPagination:function(i){let o=1;var e={root:r.querySelector(".wpforms-icon-picker-jconfirm-content-pane"),rootMargin:"600px"};new IntersectionObserver(function(e){e[0].isIntersecting&&(o++,i.show(0,o*wpforms_builder.icon_choices.icons_per_page))},e).observe(r.querySelector(".wpforms-icon-picker-pagination"))},selectIcon:function(e,i){var o=i.parent().data("field-id"),t=i.parent().data("choice-id"),r=i.data("icon"),n=i.data("icon-style"),t=b("#wpforms-field-option-row-"+o+"-choices ul li[data-key="+t+"]"),s=b("#wpforms-field-option-row-"+o+"-choices ul").data("field-type");i.addClass("selected"),i.siblings(".selected").removeClass("selected"),t.find(".wpforms-icon-select span").text(r),t.find(".wpforms-icon-select .ic-fa-preview").removeClass().addClass(`ic-fa-preview ic-fa-${n} ic-fa-`+r),t.find(".wpforms-icon-select .source-icon").val(r),t.find(".wpforms-icon-select .source-icon-style").val(n),k.fieldChoiceUpdate(s,o),e.close()}},dismissNotice:function(){v.on("click",".wpforms-alert-field-not-available .wpforms-dismiss-button",function(e){e.preventDefault();var e=b(this),i=e.closest(".wpforms-alert"),e=e.data("field-id");i.addClass("out"),setTimeout(function(){i.remove()},250),e&&b("#wpforms-field-option-"+e).remove()})},trimFormTitle:function(){var e,i=b(".wpforms-center-form-name");38<i.text().length&&(e=i.text().trim().substring(0,38).split(" ").slice(0,-1).join(" ")+"...",i.text(e))},loadColorPickers:function(){b(".wpforms-color-picker").each(function(){var e=b(this);e.hasClass("minicolors-input")&&e.minicolors("destroy"),e.minicolors({defaultValue:e.data("fallback-color")||""})})},getValidColorPickerValue:function(e){var i=e.minicolors("value"),o=_.isEqual(e.minicolors("rgbObject"),{r:0,g:0,b:0}),t=_.includes(["#000","#000000"],i),e=e.data("fallback-color")||"#000000";return o&&!t?e:i},builderHotkeys:function(){b(r).on("keydown",function(e){if(e.ctrlKey){switch(e.keyCode){case 72:b(y.$helpButton,v).trigger("click");break;case 80:l.open(wpforms_builder.preview_url);break;case 66:b(y.$embedButton,v).trigger("click");break;case 69:l.open(wpforms_builder.entries_url);break;case 83:b(y.$saveButton,v).trigger("click");break;case 81:b(y.$exitButton,v).trigger("click");break;case 191:k.openKeyboardShortcutsModal();break;case 84:b(y.$sidebarToggle,v).trigger("click");break;case 70:y.$fieldsSidebar.scrollTop(0),y.$searchInput.focus();break;default:return}return!1}})},openKeyboardShortcutsModal:function(){b(".wpforms-builder-keyboard-shortcuts").length?jconfirm.instances[jconfirm.instances.length-1].close():b.alert({title:wpforms_builder.shortcuts_modal_title,content:wpforms_builder.shortcuts_modal_msg+wp.template("wpforms-builder-keyboard-shortcuts")(),icon:"fa fa-keyboard-o",type:"blue",boxWidth:"550px",smoothContent:!1,buttons:{confirm:{text:wpforms_builder.close,btnClass:"btn-confirm",keys:["enter"]}},onOpenBefore:function(){this.$body.addClass("wpforms-builder-keyboard-shortcuts")}})},registerTemplates:function(){"undefined"!=typeof WPForms&&WPForms.Admin.Builder.Templates.add(["wpforms-builder-confirmations-message-field","wpforms-builder-conditional-logic-toggle-field"])},exitBack:function(){console.warn('WARNING! Function "WPFormsBuilder.exitBack()" has been deprecated.')}};return k}(document,window,jQuery);WPFormsBuilder.init();
|