File Editor
Directories:
.. (Back)
fields
Files:
admin-builder-providers.js
admin-builder-providers.min.js
admin-builder.js
admin-builder.min.js
context-menu.js
context-menu.min.js
drag-fields.js
drag-fields.min.js
dropdown-list.js
dropdown-list.min.js
email-template.js
email-template.min.js
form-templates.js
form-templates.min.js
help.js
help.min.js
panel-loader.js
panel-loader.min.js
providers.js
providers.min.js
search-fields.js
search-fields.min.js
settings.js
settings.min.js
setup.js
setup.min.js
templates.js
templates.min.js
wpforms-choicesjs.js
wpforms-choicesjs.min.js
Create New File
Create
Edit File: providers.min.js
var WPForms=window.WPForms||{};WPForms.Admin=WPForms.Admin||{},WPForms.Admin.Builder=WPForms.Admin.Builder||{},WPForms.Admin.Builder.Providers=WPForms.Admin.Builder.Providers||function(e,f){const u={cache:{},config:{templates:["wpforms-providers-builder-content-connection-fields","wpforms-providers-builder-content-connection-conditionals"]},fields:{}},m={panelHolder:{},form:f("#wpforms-builder-form"),spinner:'<i class="wpforms-loading-spinner wpforms-loading-inline"></i>',ajax:{_mergeData(e,r){e={id:m.form.data("id"),revision_id:m.form.data("revision"),nonce:wpforms_builder.nonce,action:"wpforms_builder_provider_ajax_"+e};return f.extend(e,r),e},request(t,e){const n=m.getProviderHolder(t),i=n.find(".wpforms-builder-provider-connections-save-lock"),d=n.find(".wpforms-builder-provider-connections-error");var r={url:wpforms_builder.ajax_url,type:"post",dataType:"json",beforeSend(){n.addClass("loading"),i.val(1),d.hide()}};return e.data=m.ajax._mergeData(t,e.data||{}),f.extend(r,e),f.ajax(r).fail(function(e,r,o){console.error("provider:",t),console.error(e),console.error(r),i.val(1),d.show()}).always(function(e,r,o){n.removeClass("loading"),"success"===r&&(i.val(0),setTimeout(function(){wpf.savedState=wpf.getFormState("#wpforms-builder-form")},0))})}},cache:{get(e,r){return void 0!==u.cache[e]&&u.cache[e]instanceof Map?u.cache[e].get(r):null},getById(e,r,o){return void 0===this.get(e,r)||void 0===this.get(e,r)[o]?null:this.get(e,r)[o]},set(e,r,o){return void 0!==u.cache[e]&&u.cache[e]instanceof Map||(u.cache[e]=new Map),u.cache[e].set(r,o)},addTo(e,r,o,t){void 0!==u.cache[e]&&u.cache[e]instanceof Map||(u.cache[e]=new Map,this.set(e,r,{}));var n=this.get(e,r);return n[o]=t,this.set(e,r,n)},delete(e,r){return void 0!==u.cache[e]&&u.cache[e]instanceof Map?u.cache[e].delete(r):null},deleteFrom(e,r,o){var t;return void 0!==u.cache[e]&&u.cache[e]instanceof Map?(delete(t=this.get(e,r))[o],this.set(e,r,t)):null},clear(e){void 0!==u.cache[e]&&u.cache[e]instanceof Map&&u.cache[e].clear()}},init(){f(m.ready)},ready(){u.fields=f.extend({},wpf.getFields(!1,!0)),m.panelHolder=f("#wpforms-panel-providers, #wpforms-panel-settings"),m.Templates=WPForms.Admin.Builder.Templates,m.Templates.add(u.config.templates),m.bindActions(),m.ui.bindActions(),m.panelHolder.trigger("WPForms.Admin.Builder.Providers.ready")},bindActions(){f(e).on("wpformsSaved",function(){var e=m.panelHolder.find(".wpforms-builder-provider-connection");if(e.length){let t=!1;e.each(function(){let o=!1;var e,r;f(this).find("input.wpforms-required, select.wpforms-required, textarea.wpforms-required").each(function(){var e=f(this),r=e.val();_.isEmpty(r)&&!e.closest(".wpforms-builder-provider-connection-block").hasClass("wpforms-hidden")?(f(this).addClass("wpforms-error"),o=!0):f(this).removeClass("wpforms-error")}),o&&!t&&((e=f(this).closest(".wpforms-builder-provider").find(".wpforms-builder-provider-title").clone()).find("button").remove(),r=wpforms_builder.provider_required_flds,f.alert({title:wpforms_builder.heads_up,content:r.replace("{provider}","<strong>"+e.text().trim()+"</strong>"),icon:"fa fa-exclamation-circle",type:"red",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}}),t=!0)}),"fields"===wpf.getQueryString("view")&&m.updateMapSelects(e)}}),m.panelHolder.on("connectionRendered",function(){!0===wpf.initialSave&&(wpf.savedState=wpf.getFormState("#wpforms-builder-form"))})},updateMapSelects(r){var e=f.extend({},wpf.getFields()),o=_.mapObject(e,function(e,r){return e.label}),t=_.mapObject(u.fields,function(e,r){return e.label});if(!(_.isEmpty(o)&&_.isEmpty(t)||JSON.stringify(o)===JSON.stringify(t))){const d=Object.keys(o).map(function(e){return parseInt(e,10)});var n=Object.keys(t).map(function(e){return parseInt(e,10)}).filter(function(e){return!d.includes(e)});for(let e=0;e<n.length;e++)f('.wpforms-builder-provider-connection-fields-table .wpforms-builder-provider-connection-field-value option[value="'+n[e]+'"]',r).remove();const s=[],a=[];for(const c in e){const l=e[c];var i=l.id;const p=wpf.sanitizeHTML(l.label?.toString().trim()||wpforms_builder.field+" #"+i);s.push({value:i,text:p}),"name"===l.type&&l.format?f.each(wpforms_builder.name_field_formats,function(e,r){-1===l.format.indexOf(e)&&"full"!==e||a.push({value:l.id+"."+e,text:p+" ("+r+")"})}):a.push({value:i,text:p})}f(".wpforms-builder-provider-connection-fields-table .wpforms-builder-provider-connection-field-value").each(function(){var e=f(this);const r=e.val(),o=e.clone().empty();var t=e.data("support-subfields")||Boolean(e.find('option[value$=".first"]').length)?a:s;o.append(f("<option>",{value:"",text:wpforms_builder_providers.custom_fields_placeholder})),t.forEach(function(e){o.append(f("<option>",{value:e.value,text:e.text,selected:r.toString()===e.value.toString()}))}),e.replaceWith(o)}),wpf.savedState!==wpf.getFormState("#wpforms-builder-form")&&(wpf.savedState=wpf.getFormState("#wpforms-builder-form")),u.fields=e,m.panelHolder.trigger("WPForms.Admin.Builder.Providers.updatedMapSelects",[r,e])}},ui:{bindActions(){m.panelHolder.on("click",".js-wpforms-builder-provider-account-add",function(e){e.preventDefault(),m.ui.account.setProvider(f(this).data("provider")),m.ui.account.add()}).on("click",".js-wpforms-builder-provider-connection-add",function(e){e.preventDefault(),m.ui.connectionAdd(f(this).data("provider"))}).on("click",".js-wpforms-builder-provider-connection-delete",function(e){var r=f(this);e.preventDefault(),m.ui.connectionDelete(r.closest(".wpforms-builder-provider").data("provider"),r.closest(".wpforms-builder-provider-connection"))}),m.panelHolder.on("click",".js-wpforms-builder-provider-connection-fields-add",function(e){e.preventDefault();var e=f(this).parents(".wpforms-builder-provider-connection-fields-table"),r=e.find("tr").last().clone(!0),o=parseInt(/\[.+]\[.+]\[.+]\[(\d+)]/.exec(r.find(".wpforms-builder-provider-connection-field-name").attr("name"))[1],10)+1;r.find(".wpforms-builder-provider-connection-field-name").attr("name",r.find(".wpforms-builder-provider-connection-field-name").attr("name").replace(/\[fields_meta\]\[(\d+)\]/g,"[fields_meta]["+o+"]")).val(""),r.find(".wpforms-builder-provider-connection-field-value").attr("name",r.find(".wpforms-builder-provider-connection-field-value").attr("name").replace(/\[fields_meta\]\[(\d+)\]/g,"[fields_meta]["+o+"]")).val(""),r.find(".js-wpforms-builder-provider-connection-fields-delete").removeClass("hidden"),e.find("tbody").append(r.get(0))}).on("click",".js-wpforms-builder-provider-connection-fields-delete",function(e){e.preventDefault(),f(this).parents(".wpforms-builder-provider-connection-fields-table tr").remove()}),m.panelHolder.on("connectionGenerated",function(e,r){wpf.initTooltips(),f(this).find('.wpforms-builder-provider-connection[data-connection_id="'+r.connection.id+'"]').closest(".wpforms-panel-content-section").find(".wpforms-builder-provider-connections-default").addClass("wpforms-hidden")}),m.panelHolder.on("connectionRendered",function(e,r,o){if(wpf.initTooltips(),void 0===o){if(!_.isObject(r)||!_.has(r,"connection_id"))return;o=r.connection_id}f(this).find('.wpforms-builder-provider-connection[data-connection_id="'+o+'"] .wpforms-field-map-select').length&&wpf.fieldUpdate()}),m.panelHolder.on("change",".wpforms-builder-provider select.wpforms-required",function(){var e=f(this);e.hasClass("wpforms-error")&&0!==e.val().length&&e.removeClass("wpforms-error")}),m.panelHolder.on("connectionDeleted",function(e){m.ui.updateStatus(e)})},connectionAdd(o){f.confirm({title:!1,content:wpforms_builder_providers.prompt_connection.replace(/%type%/g,"connection")+'<input autofocus="" type="text" id="wpforms-builder-provider-connection-name" placeholder="'+wpforms_builder_providers.prompt_placeholder+'"><p class="error">'+wpforms_builder_providers.error_name+"</p>",icon:"fa fa-info-circle",type:"blue",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"],action(){var e=this.$content.find("#wpforms-builder-provider-connection-name").val().trim(),r=this.$content.find(".error");if(""===e)return r.show(),!1;m.getProviderHolder(o).trigger("connectionCreate",[e])}},cancel:{text:wpforms_builder.cancel}}})},connectionDelete(r,o){f.confirm({title:!1,content:wpforms_builder_providers.confirm_connection,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"],action(){m.getProviderHolder(r).trigger("connectionDelete",[o]);const e=o.closest(".wpforms-panel-content-section");o.fadeOut("fast",function(){f(this).remove(),m.getProviderHolder(r).trigger("connectionDeleted",[o]),e.find(".wpforms-builder-provider-connection").length||e.find(".wpforms-builder-provider-connections-default").removeClass("wpforms-hidden")})}},cancel:{text:wpforms_builder.cancel}}})},updateStatus(e){var r=e.target.closest(".wpforms-panel-content-section");f(".wpforms-panel-sidebar-section-"+e.target.dataset.provider).find(".fa-check-circle-o").toggleClass("wpforms-hidden",f(r).find(".wpforms-builder-provider-connection").length<=0)},account:{provider:"",submitHandlers:[],setProvider(e){this.provider=e},add(){const t=this;f.confirm({title:!1,smoothContent:!0,content(){const r=this;return m.ajax.request(t.provider,{data:{task:"account_template_get"}}).done(function(e){e.success&&(e.data.title.length&&r.setTitle(e.data.title),e.data.content.length&&r.setContent(e.data.content),e.data.type.length&&r.setType(e.data.type),m.getProviderHolder(t.provider).trigger("accountAddModal.content.done",[r,t.provider,e]))}).fail(function(){m.getProviderHolder(t.provider).trigger("accountAddModal.content.fail",[r,t.provider])}).always(function(){m.getProviderHolder(t.provider).trigger("accountAddModal.content.always",[r,t.provider])})},contentLoaded(e,r,o){this.buttons.add.enable(),this.buttons.cancel.enable(),m.getProviderHolder(t.provider).trigger("accountAddModal.contentLoaded",[this])},onOpenBefore(){this.buttons.add.disable(),this.buttons.cancel.disable(),this.$body.addClass("wpforms-providers-account-add-modal"),m.getProviderHolder(t.provider).trigger("accountAddModal.onOpenBefore",[this])},onClose(){!0===m.ui.account.isConfigured(t.provider)&&m.ui.connectionAdd(t.provider)},icon:"fa fa-info-circle",type:"blue",buttons:{add:{text:wpforms_builder.provider_add_new_acc_btn,btnClass:"btn-confirm",keys:["enter"],action(){if(m.getProviderHolder(t.provider).trigger("accountAddModal.buttons.add.action.before",[this]),!_.isEmpty(t.provider)&&void 0!==t.submitHandlers[t.provider])return t.submitHandlers[t.provider](this)}},cancel:{text:wpforms_builder.cancel}}})},registerAddHandler(e,r){"string"==typeof e&&"function"==typeof r&&(this.submitHandlers[e]=r)},isConfigured(e){return m.getProviderHolder(e).find(".js-wpforms-builder-provider-account-add").hasClass("hidden")}}},getProviderHolder(e){return f("#"+e+"-provider")}};return m}(document,(window,jQuery)),WPForms.Admin.Builder.Providers.init();
Save Changes
Rename File
Rename