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

1 line
50 KiB
JavaScript
Raw Normal View History

2023-04-09 19:52:26 +05:00
function t_forms__onReady(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t)}window.t_forms__lang=(window.navigator.userLanguage||window.navigator.language).toUpperCase().slice(0,2),window.scriptSysPayment={},window.handlerSysPayment={},window.isInitEventsZB={},window.isInitEventsCustomMask={},window.initForms={},window.tildaForm={versionLib:"02.001",endpoint:"forms.tildacdn.com",isRecaptchaScriptInit:!1,currentFormProccessing:!1},t_forms__onReady((function(){var t=document.getElementById("allrecords");if(t){var e=t.getAttribute("data-tilda-project-lang");e&&(window.t_forms__lang=e)}t_forms__initForms();var r=!!document.querySelector(".t706"),o=!!document.querySelector(".js-payment-systembox"),a=!!document.querySelector("input[name=tld_product]");if(r||o||a){var n="tilda-forms-payments-1.0",i;if(!document.head.querySelector('script[src*="'+n+'"]'))(i=document.createElement("script")).type="text/javascript",i.src="https://static.tildacdn.com/js/"+n+".min.js",i.onerror=function(){console.error("Failed to load tilda-forms-payments: ",this.src)},document.head.appendChild(i)}var s=window.t_forms__lang;if("RU"!==s&&"EN"!==s){var n="tilda-forms-dict-1.0",i;if(!document.head.querySelector('script[src*="'+n+'"]'))(i=document.createElement("script")).type="text/javascript",i.src="https://static.tildacdn.com/js/"+n+".min.js",i.onerror=function(){console.error("Failed to load tilda-forms-dictionary: ",this.src)},document.head.appendChild(i)}})),window.tildaForm.captchaCallback=function(){if(!window.tildaForm.currentFormProccessing||!window.tildaForm.currentFormProccessing.form)return!1;window.tildaForm.send(window.tildaForm.currentFormProccessing.form,window.tildaForm.currentFormProccessing.btn,window.tildaForm.currentFormProccessing.formtype,window.tildaForm.currentFormProccessing.formskey),window.tildaForm.currentFormProccessing=!1},window.tildaForm_customMasksLoad=function(){if(!0!==window.isInitEventsCustomMask){var t=document.createElement("script");t.type="text/javascript",t.src="https://static.tildacdn.com/js/tilda-forms-custommask-1.0.min.js",document.head.appendChild(t),window.isInitEventsCustomMask=!0}},window.tildaForm_initMasks=function(){var t=document.querySelectorAll(".js-tilda-mask");if(t.length&&!0!==window.isInitEventsCustomMask)return window.tildaForm_customMasksLoad(),void window.setTimeout((function(){window.tildaForm_initMasks()}),100);!0===window.isInitEventsCustomMask&&Array.prototype.forEach.call(t,(function(t){t_asyncLoad(t)}))},t_forms__onReady((function(){window.tildaForm_initMasks()})),window.tildaForm.validate=function(t){t instanceof Element||(t=t[0]);for(var e=t.querySelectorAll(".js-tilda-rule"),r=[],o=!0,a=0;a<e.length;a++){var n=e[a],i=!!parseInt(n.getAttribute("data-tilda-req")||0,10),s=n.getAttribute("data-tilda-rule")||"none",l="",d="",c=n.getAttribute("data-tilda-rule-minlength")||0,u=n.getAttribute("data-tilda-rule-maxlength")||0,m={},p=n.value,f="",_=n.getAttribute("type"),y=n.getAttribute("name"),w=t.getAttribute("data-formcart");m.obj=n,m.type=[],p&&p.length&&(f=p.replace(/[\s\u0000—\u001F\u2000-\u200F\uFEFF\u2028-\u202F\u205F-\u206F]/gi,""),p=p.trim()),p.length>0&&(o=!1),c&&(c=parseInt(c,10)),u&&(u=parseInt(u,10));var h=!p.length&&!f.length,g="checkbox"===_||"radio"===_,v=!t.querySelectorAll('[name="'+y+'"]:checked').length;if(i&&(h||g&&v))m.type.push("req");else{switch(s){case"email":l=/^(?!\.)(?!.*\.\.)[a-zA-Zёа-яЁА-Я0-9\u2E80-\u2FD5\u3190-\u319f\u3400-\u4DBF\u4E00-\u9FCC\uF900-\uFAAD_\.\-\+]{0,63}[a-zA-Zёа-яЁА-Я0-9\u2E80-\u2FD5\u3190-\u319f\u3400-\u4DBF\u4E00-\u9FCC\uF900-\uFAAD_\-\+]@[a-zA-Zёа-яЁА-ЯЁёäöüÄÖÜßèéû0-9][a-zA-Zёа-яЁА-ЯЁёäöüÄÖÜßèéû0-9\.\-]{0,253}\.[a-zA-Zёа-яЁА-Я]{2,10}$/gi,p.length&&!p.match(l)&&m.type.push("email");break;case"url":l=/^((https?|ftp):\/\/)?[a-zA-Zёа-яЁА-ЯЁёäöüÄÖÜßèéûşç0-9][a-zA-Zёа-яЁА-ЯЁёäöüÄÖÜßèéûşç0-9_\.\-]{0,253}\.[a-zA-Zёа-яЁА-Я]{2,10}\/?$/gi,p.length&&((d=(d=(d=p.split("//"))&&d.length>1?d[1]:d[0]).split("/"))&&d.len