core/1/iiko_files/tilda-zero-forms-1.0.min.js

1 line
45 KiB
JavaScript
Raw Normal View History

2023-04-09 19:52:26 +05:00
var version;function t_zeroForms__init(t,e,r){var o,n,i=document.getElementById("rec"+t),a=i?i.querySelector('.tn-elem[data-elem-id="'+e+'"]'):null;a&&(o=t_zeroForms__getTildaMode(),n=document.querySelector('script[src*="tilda-blocks-2.7"]'),t_zeroForms__waitForTN(function(){t_zeroForms__renderForm(a,r,t,o)}),t_zeroForms__onFuncLoad("t396_elem__renderViewOneField",function(){t396_elem__renderViewOneField(n?$(a):a,"left"),t396_elem__renderViewOneField(n?$(a):a,"top")}))}function t_zeroForms__waitForTN(t){window.tn&&window.tn.curResolution?t():setTimeout(function(){t_zeroForms__waitForTN(t)},300)}function t_zeroForms__renderForm(t,e,r,o){if(t=t_zeroForms__getEl(t),o=o||t_zeroForms__getTildaMode(),r||"zero"===o||"edit"===o||(r=t.closest(".r").id.replace("rec","")),"string"==typeof e)try{e=JSON.parse(e)}catch(t){}var n=document.querySelector(".t-records"),n=(n=!!n&&"edit"===n.getAttribute("data-tilda-mode"))||"published"!==o;if(!t.classList.contains("zero-form-rendered")||n){n=t.closest(".r");if(!t_zeroForms__isRecordHidden(n)&&!t_zeroForms__isFormOutside(t)||"published"!==o){if(!e){n=t.querySelector(".tn-atom__inputs-textarea");if(n&&n.value)try{e=JSON.parse(n.value)}catch(t){e={}}else e={}}n=t_zeroForms__fromObjToArray(e),e=t.querySelector(".tn-atom");if("zero"===o||"edit"===o)e.innerHTML="";else if(e.querySelector(".t-form"))return;r=t_zeroForms__createForm(r,o,n,t);r&&(e.insertAdjacentElement("beforeend",r),(o=document.createEvent("Event")).initEvent("render",!0,!0),t.dispatchEvent(o),t.classList.add("zero-form-rendered"),t_zeroForms__initMaskAfterRender(t))}}}function t_zeroForms__initMaskAfterRender(t){t_zeroForms__onRender(t,!0,function(){t.querySelector(".js-tilda-mask")&&t_zeroForms__onFuncLoad("tildaForm_initMasks",function(){setTimeout(function(){t.querySelector('.js-tilda-mask:not([data-tilda-mask-init="1"])')&&tildaForm_initMasks()},500)})})}function t_zeroForms__createForm(e,t,r,o){t=t||t_zeroForms__getTildaMode();var n=t_zeroForms__createFormObj(o),i="published"===t,a=r.filter(function(t){return"y"!==t.loff&&"hd"!==t.li_type}),s=document.createElement(i?"form":"div");s.classList.add("t-form"),s.classList.add("t-form_inputs-total_"+a.length),n.inputsstyle&&s.classList.add("t-form_bbonly"),"h"===n.inputpos&&s.classList.add("tn-form_horiz"),i&&(s.id="form"+e,s.name="form"+e,s.action="https://forms.tildacdn.com/procces/",s.method="POST",s.classList.add("js-form-proccess"),s.setAttribute("role","form"),s.setAttribute("data-formactiontype","2"),s.setAttribute("data-inputbox",".t-input-group"),s.setAttribute("data-success-callback","t396_onSuccess"),s.setAttribute("data-success-popup","y"),s.setAttribute("data-error-popup","y"),n.formmsgurl&&s.setAttribute("data-success-url",n.formmsgurl));(n.receivers?n.receivers.split(","):[]).forEach(function(t){t=t_zeroForms__createHiddenField(t,"formservices[]","js-formaction-services");s.insertAdjacentElement("beforeend",t)}),n.formname&&(a=t_zeroForms__createHiddenField(n.formname,"tildaspec-formname",""),s.insertAdjacentElement("beforeend",a));var l,d,i=document.createElement("div"),a=(i.classList.add("js-successbox"),i.classList.add("t-form__successbox"),i.classList.add("t-text"),i.classList.add("t-text_sm"),i.style.display="none",i.innerHTML=n.formmsgsuccess,s.insertAdjacentElement("beforeend",i),{color:n.inputtitlecolor||"",fontWeight:n.inputtitlefontweight||"",fontFamily:n.inputfontfamily||"",fontSize:n.inputtitlefontsize||"",paddingBottom:n.inputtitlemargbottom||""}),i=t_zeroForms__generateInputsBlock(e,o,r,n,a),c=(s.insertAdjacentElement("beforeend",i),o.getAttribute("data-elem-id")),a=(n.formbottomtext&&((r=document.createElement("div")).style.textAlign="center"===n.buttonalign?"center":"left",r.style.color=a.color,r.style.fontWeight=a.fontWeight,r.style.fontFamily=a.fontFamily,r.style.marginTop="15px",r.style.fontSize="13px",i=t_zeroForms__getBottomText(c,n,e,o),r.appendChild(i),s.insertAdjacentElement("beforeend",r)),s.insertAdjacentElement("beforeend",t_zeroForms__createErrorBox(n,"bottom")),s.insertAdjacentElement("beforeend",t_zeroForms__createCommentField()),t_z