File: /var/www/html/wppartneramazingsecret/wp-content/plugins/builder-contact/assets/admin.min.js
'use strict';(function(A){let z;const C=function(a,b){this.$table=A(a);this.top=window.top.document;this.init(b)};C.prototype={$table:null,app:null,init(a){this.app=a;this.loadExtraFields(a.values);this.makeSortable();this.events()},loadOrders(a,b){let c,d;try{c=JSON.parse(a.field_order)}catch(e){}c||(c={});a=this.$table[0].getElementsByTagName("tbody")[0];const f=a.getElementsByTagName("tr"),g=[],k=document.createDocumentFragment();for(let e=0,m=f.length;e<m;++e)f[e].classList.contains("tb_no_sort")?
d=f[e]:g.push(f[e]);g.sort(function(e,m){let p;var h=e.classList.contains("tb_contact_new_row");var q=m.classList.contains("tb_contact_new_row");let u=function(r){for(let n=b.length-1;-1<n;--n)if((b[n].label===r||b[n].id===r)&&void 0!==b[n].order)return b[n].order;return!1};e=h?e.getElementsByClassName("tb_new_field_textbox")[0]:e.getElementsByClassName("tb_lb_option")[0];m=q?m.getElementsByClassName("tb_new_field_textbox")[0]:m.getElementsByClassName("tb_lb_option")[0];h&&e.dataset.order?h=e.dataset.order:
(p=h?e.value:e.id,p=h&&""===p?e.dataset.id:p,p=p.trim(),h=void 0!==c[p]?c[p]:h?u(p):!1);q&&m.dataset.order?q=m.dataset.order:(e=q?m.value:m.id,e=q&&""===e?m.dataset.id:e,e=e.trim(),q=void 0!==c[e]?c[e]:q?u(e):!1);return h-q});for(let e=0,m=g.length;e<m;++e)k.appendChild(g[e]);for(k.appendChild(d);a.firstChild;)a.removeChild(a.lastChild);a.appendChild(k)},loadExtraFields(a){let b,c=this.$table[0].getElementsByClassName("tb_no_sort")[0];try{b=JSON.parse(a.field_extra).fields}catch(f){}b||(b={fields:[]});
const d=document.createDocumentFragment();for(let f=0,g=b.length;f<g;++f)d.appendChild(this.addField(b[f]));c.parentNode.insertBefore(d,c);this.loadOrders(a,b)},events(){const a=this;this.$table.on("click.tb_contact",".tb_new_field_action",function(b){b.preventDefault();b.stopPropagation();b=this.closest(".tb_no_sort");b.parentNode.insertBefore(a.addField({}),b);a.$table.find("tbody").sortable("refresh");a.changeObject()}).on("change.tb_contact",".tb_new_field_type",function(){a.switchField(this);
a.changeObject()}).on("click.tb_contact",".tb_add_field_option",function(b){b.preventDefault();b.stopPropagation();this.previousElementSibling.appendChild(a.render.getOptions([""]));a.changeObject()}).on("keyup.tb_contact",'.tb_contact_new_row input[type="text"], .tb_contact_new_row textarea',function(){a.changeObject()}).on("change.tb_contact",".tb_contact_new_row .tb_new_field_required",function(){a.changeObject()}).on("click.tb_contact",".tb_contact_value_remove,.tb_contact_field_remove",function(b){b.preventDefault();
b.stopPropagation();if(this.classList.contains("tb_contact_value_remove"))A(this).closest("li").remove();else{b=A(this).closest(".tb_contact_new_row");let c=b.find(".tb_new_field_textbox").val().trim();b.remove();[...ThemifyBuilderCommon.Lightbox.$lightbox[0].querySelectorAll(".tb_contact_custom_tags span")].filter(function(d){d.textContent.trim()==="%"+c+"%"&&d.parentNode.removeChild(d)})}a.changeObject()})},makeSortable(){const a=this;this.$table.find("tbody").sortable({items:"tr:not(.tb_no_sort)",
placeholder:"ui-state-highlight",axis:"y",containment:"parent",update(){a.changeObject()}})},render:{call(a,b){return void 0===this[b]?this._default(a,b):this[b].call(this,a,b)},setType(a,b){a.setAttribute("data-type",b)},getText(a,b,c){const d=document.createElement(c);"textarea"!==c&&(d.type="tel"!==c?"text":"tel");a.value&&(d.value=a.value.replace(/"/g,'"'));d.className="tb_new_field_value tb_field_type_text";this.setType(d,b);return d},static(a,b){a=this._default(a,"textarea");a.placeholder=
tb_contact_l10n.static_text;this.setType(a,"static");return a},upload(a,b){return document.createElement("div")},getOptions(a){const b=document.createDocumentFragment();for(let c in a){let d=document.createElement("li"),f=document.createElement("a"),g=document.createElement("input");g.type="text";g.className="tb_multi_option";g.value=a[c];f.className="tb_contact_value_remove tf_close";f.href="#";d.appendChild(g);d.appendChild(f);b.appendChild(d)}return b},_default(a,b){if("text"===b||"textarea"===
b||"tel"===b)return this.getText(a,b,"textarea"===b?b:"input");const c=document.createElement("ul"),d=document.createElement("a"),f=document.createDocumentFragment();c.appendChild(this.getOptions(a.value||[""]));f.appendChild(c);d.href="#";d.className="tb_add_field_option";d.textContent=tb_contact_l10n.add_option;this.setType(d,b);f.appendChild(d);return f}},addField(a){var b=0===Object.keys(a).length;const c=a.type?a.type:"text",d=document.createElement("tr"),f=document.createElement("td"),g=document.createElement("input"),
k=document.createElement("td"),e=document.createElement("div"),m=document.createElement("select"),p=document.createDocumentFragment(),h=document.createElement("div"),q=document.createElement("div"),u=document.createElement("label"),r=document.createElement("input"),n=document.createElement("a"),t=tb_contact_l10n.types,x="tb_"+tb_app.Utils.generateUniqueID();h.className="control-input tf_rel";q.className="tb_new_field";e.className="selectwrapper";m.className="tb_new_field_type tb_lb_option";d.className=
"tb_contact_new_row";g.type="text";g.className="tb_new_field_textbox";g.value=void 0===a.label?!0===b?tb_contact_l10n.field_name:"":a.label.replace(/"/g,'"');g.dataset.id=void 0===a.id?"":a.id;g.dataset.order=void 0===a.order?"":a.order;r.type="checkbox";r.className="tb_new_field_required";r.value="required";"static"===c&&(u.style.display="none");!0===a.required&&(r.checked=!0);k.setAttribute("colspan","2");f.appendChild(g);d.appendChild(f);for(let l in t)b=document.createElement("option"),b.name=
x,l===c&&(b.selected="selected"),b.value=l,b.textContent=t[l],p.appendChild(b);m.appendChild(p);e.appendChild(m);k.appendChild(e);h.appendChild(this.render.call(a,c));q.appendChild(h);u.appendChild(r);u.appendChild(document.createTextNode(tb_contact_l10n.req));q.appendChild(u);k.appendChild(q);d.appendChild(k);a=document.createElement("td");a.appendChild(n);n.className="tb_contact_field_remove tf_close";n.href="#";d.appendChild(a);let y=document.createElement("span");y.appendChild(document.createTextNode("%"+
g.value+"%"));ThemifyBuilderCommon.Lightbox.$lightbox[0].querySelector(".tb_contact_custom_tags").appendChild(y);g.addEventListener("change",function(){y.textContent="%"+this.value+"%"});return d},switchField(a){const b=a.value;a=a.closest("td").getElementsByClassName("control-input")[0];const c=a.closest(".tb_new_field").getElementsByClassName("tb_new_field_required")[0].parentNode;for(;a.firstChild;)a.removeChild(a.lastChild);a.appendChild(this.render.call({},b));c.style.display="static"===b?"none":
""},changeObject(a){var b=this.$table[0].getElementsByTagName("tbody")[0].getElementsByTagName("tr");const c={fields:[]};var d={};for(let k=0,e=b.length;k<e;++k)if(b[k].classList.contains("tb_contact_new_row")){var f=b[k].getElementsByClassName("tb_new_field_type")[0].options[b[k].getElementsByClassName("tb_new_field_type")[0].selectedIndex].value;let m=b[k].getElementsByClassName("tb_new_field_textbox")[0].value.trim(),p="static"!==f&&!0===b[k].getElementsByClassName("tb_new_field_required")[0].checked,
h;switch(f){case "text":case "textarea":case "static":case "tel":h=b[k].getElementsByClassName("tb_new_field_value")[0].value.trim();break;case "radio":case "select":case "checkbox":h=[];var g=b[k].getElementsByClassName("control-input")[0].getElementsByTagName("input");for(let q=0,u=g.length;q<u;++q){let r=g[q].value.trim();""===r&&"select"!==f||h.push(r)}}if(""!==h&&void 0!==h||""!==m){g={type:f,order:k};p&&(g.required=p);""!==m?g.label=m.replace(/"/g,"""):g.id="ex"+k;if(void 0!==h&&""!==h&&
0<h.length){if("static"===f)h=h.replace(/"/g,'\\\\"');else if("text"===f||"textarea"===f)h=h.replace(/"/g,""");if("static"===f||"textarea"===f)h=h.replace(/\n/g,"\\\\n");g.value=h}c.fields.push(g)}}else b[k].classList.contains("tb_no_sort")||(f=b[k].getElementsByClassName("tb_lb_option")[0].id,d[f]=k);b=this.top.getElementById("field_extra");d=JSON.stringify(d);b.value=JSON.stringify(c);this.top.getElementById("field_order").value=d;this.app.settings.field_order=d;a||Themify.triggerEvent(b,"change")}};
let D=null;tb_app.Constructor.contact_fields={render(a,b){var c=window.top;null===D&&(D=!0,c.Themify.LoadCss(tb_contact_l10n.admin_css,tb_contact_l10n.v));c=document.createElement("tr");const d=document.createElement("table"),f=document.createElement("thead"),g=document.createElement("tbody"),k=document.createElement("tfoot"),e=document.createDocumentFragment(),m=a.options.head;var p=a.options.body;const h=a.options.foot,q={text(l,v,w){l={id:"field_"+l,placeholder:v,"class":"large",type:"text"};w&&
(l.help=w);return b.create([l])},checkbox(l){const v={id:"field_"+l,new_line:!0,type:"checkbox",options:[{value:"",name:"yes"}]};"sendcopy_active"===l?v.binding={checked:{show:"field_sendcopy_subject"},not_checked:{hide:"field_sendcopy_subject"}}:"optin_active"===l&&(v.binding={checked:{show:"optin"},not_checked:{hide:"optin"}});return b.create([v])}};for(var u in m){var r=document.createElement("th");"l"===u&&(r.colSpan=2);r.textContent=m[u];c.appendChild(r)}f.appendChild(c);for(var n in p){c=document.createElement("tr");
for(var t in m){u=document.createElement("td");r=null;if("f"===t)r=document.createElement("span"),u.textContent=p[n];else if("l"===t){if(u.colSpan="2",r=q.text(n+"_label",p[n]),r.appendChild(q.text(n+"_placeholder",tb_contact_l10n.pl)),"message"!==n){var x=document.createDocumentFragment(),y=q.checkbox(n+"_require");x.appendChild(r);y.querySelector(".tb_lb_option").appendChild(document.createTextNode(tb_contact_l10n.req));x.appendChild(y);r=x}}else"sh"===t&&(r=q.checkbox(n+"_active"));null!==r&&u.appendChild(r);
c.appendChild(u)}e.appendChild(c)}c=document.createElement("tr");n=document.createElement("td");t=document.createElement("a");p=document.createElement("span");t.className="tb_new_field_action";t.href="#";p.className="tf_plus_icon";t.appendChild(p);t.appendChild(document.createTextNode(a.new_row));n.setAttribute("colspan","4");n.appendChild(t);c.className="tb_no_sort";c.appendChild(n);e.appendChild(c);g.appendChild(e);for(let l in h)if("align"!==l){c=document.createElement("tr");for(let v in m)if("sh"!==
v||"send"!==l)a=document.createElement("td"),t=null,"f"===v?a.textContent=h[l]:"l"===v?(a.colSpan=2,n=q.text(l+"_label",h[l]),"send"===l?(a.colSpan=3,x=document.createDocumentFragment(),t=b.select.render({id:h.align.id,options:h.align.options},b),x.appendChild(n),x.appendChild(t),x.appendChild(document.createTextNode(h.align.label)),t=x):"optin"===l?(t=document.createDocumentFragment(),p=ThemifyConstructor.create([{type:"optin_provider",id:"optin"}]),t.appendChild(n),t.appendChild(p)):t=n,x.appendChild(y)):
"sh"===v&&"send"!==l&&(t=q.checkbox(l+"_active"),"captcha"===l&&""!==tb_contact_l10n.captcha&&t.querySelector("input").addEventListener("change",function(w){w=this.closest("td").previousElementSibling;if(!0===this.checked){const B=document.createElement("div");B.className="tb_captcha_message tb_field_error_msg";B.innerHTML=tb_contact_l10n.captcha;w.appendChild(B)}else w=w.getElementsByClassName("tb_captcha_message")[0],"undefined"!==typeof w&&w.parentNode.removeChild(w)},{passive:!0})),null!==t&&
a.appendChild(t),"l"===v&&"sendcopy"===l&&a.appendChild(b.create([{id:"field_"+l+"_subject",after:tb_contact_l10n.sendcopy_sub,type:"text","class":"small"}])),c.appendChild(a);e.appendChild(c)}k.appendChild(e);d.className="contact_fields";d.appendChild(f);d.appendChild(g);d.appendChild(k);document.addEventListener("tb_editing_contact",function(l){const v=ThemifyBuilderCommon.Lightbox.$lightbox;l=v.find("#template");""===l.val()&&l.val(tb_contact_l10n.default_template);z=new C(d,b);Themify.body.one("themify_builder_lightbox_close",
function(w){z.$table.off("click.tb_contact keyup.tb_contact change.tb_contact");z=null});v[0].querySelector(".template_fields").addEventListener("click",function(w){"span"===w.target.tagName.toLocaleLowerCase()&&(v[0].querySelector("#template").value+=w.target.textContent)})},{once:!0});return d}};"visual"===tb_app.mode&&(document.addEventListener("tb_inline_item",function(a){if(z){var b=a.detail.activeEl;if(null!==b.parentNode.closest(".builder-contact-field-extra")){const c=ThemifyBuilderCommon.Lightbox.$lightbox[0],
d=b.previousElementSibling?b.previousElementSibling.type:null,f=b.getAttribute("data-name");delete ThemifyConstructor.settings[f];"checkbox"===d||"order"===d?(b=Themify.convert(b.closest(".control-input").querySelectorAll("[data-name]")).indexOf(b),a.detail.el=c.querySelector('[data-order="'+f+'"]').closest(".tb_contact_new_row").getElementsByClassName("tb_multi_option")[b]):a.detail.el=c.querySelector('[data-order="'+f+'"]');z.changeObject(!0)}}},{passive:!0}),document.addEventListener("tb_inline_save",
function(a){const b=a.detail.activeEl;if(null!==b.parentNode.closest(".builder-contact-field-extra")){const c=b.getAttribute("data-name"),d=a.detail.data;a=a.detail.val;const f=JSON.parse(d.field_extra).fields;delete d[c];for(let g=f.length-1;-1<g;--g)if(f[g].order==c){if(!Array.isArray(f[g].value)||b.parentNode.classList.contains("control-label"))f[g].label=a;else for(let k=b.closest(".control-input").children,e=k.length-1;-1<e;--e)if(k[e].contains(b)){f[g].value[e]=a;break}break}d.field_extra=JSON.stringify({fields:f})}},
{passive:!0}))})(jQuery);