; /* Start:"a:4:{s:4:"full";s:100:"/bitrix/templates/dresscode/components/bitrix/sale.account.pay/.default/script.min.js?17077613673463";s:6:"source";s:81:"/bitrix/templates/dresscode/components/bitrix/sale.account.pay/.default/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ BX.saleAccountPay=function(){function e(e){this.messages=e.alertMessages||{},this.nameValue=e.nameValue||"buyMoney",this.ajaxUrl=e.url,this.signedParams=e.signedParams||{},this.wrapperId=e.wrapperId||"",this.templateFolder=e.templateFolder,this.wrapper=document.getElementById("bx-sap"+this.wrapperId),this.changeInputContainer=this.wrapper.getElementsByClassName("sale-acountpay-fixedpay-container")[0],this.paySystemsContainer=this.wrapper.getElementsByClassName("sale-acountpay-pp")[0],this.inputElement=this.wrapper.getElementsByClassName("sale-acountpay-input")[0],this.submitButton=this.wrapper.getElementsByClassName("btn")[0],this.checkboxList=this.wrapper.getElementsByClassName("sale-acountpay-pp-company"),BX.ready(BX.proxy(this.init,this))}return e.prototype.init=function(){return this.checkboxList[0].checked="checked",BX.bindDelegate(this.paySystemsContainer,"click",{className:"sale-acountpay-pp-company"},BX.proxy(function(e){var t=this.wrapper.querySelectorAll(".sale-acountpay-pp-company-checkbox:checked"),t=(Array.prototype.forEach.call(t,function(e){e.checked=!1,e.parentNode.parentNode.classList.remove("bx-selected")}),e.target.parentNode);return t.classList.add("bx-selected"),t.parentNode.classList.add("bx-selected"),t.querySelector(".sale-acountpay-pp-company-checkbox").checked="checked",this},this)),BX.bind(this.inputElement,"input",BX.delegate(function(){this.inputElement.value=this.inputElement.value.replace(/[^\d,.]*/g,"").replace(/\,/g,".").replace(/([,.])[,.]+/g,"$1").replace(/^[^\d]*(\d+([.,]\d{0,5})?).*$/g,"$1")},this)),BX.bindDelegate(this.changeInputContainer,"click",{className:"sale-acountpay-fixedpay-item"},BX.proxy(function(e){this.inputElement.value=parseInt(e.target.innerText)},this)),BX.bind(this.submitButton,"click",BX.delegate(function(e){if(e.preventDefault(),parseFloat(this.inputElement.value)<=0||""==this.inputElement.value)return window.alert(BX.util.htmlspecialchars(this.messages.wrongInput)),!1;this.startLoader(),BX.ajax({method:"POST",dataType:"html",url:this.ajaxUrl,data:{sessid:BX.bitrix_sessid(),buyMoney:this.inputElement.value,paySystemId:this.wrapper.querySelector(".sale-acountpay-pp-company-checkbox:checked").value,signedParamsString:this.signedParams},onsuccess:BX.proxy(function(e){for(;this.wrapper.firstChild;)this.wrapper.removeChild(this.wrapper.firstChild);this.wrapper.innerHTML=e,this.endLoader()},this),onfailure:BX.proxy(function(){return this},this)},this),this.destroy()},this)),this},e.prototype.destroy=function(){this.messages=null,this.nameValue=null,this.signedParams=null,this.changeInputContainer=null,this.paySystemsContainer=null,this.inputElement=null,this.submitButton=null,this.checkboxList=null},e.prototype.startLoader=function(){return!0!==this.BXFormPosting&&(this.BXFormPosting=!0,this.loadingScreen||(this.loadingScreen=new BX.PopupWindow("loading_screen",this.submitButton,{overlay:{backgroundColor:"white",opacity:"80"},autoHide:!0,events:{onAfterPopupShow:BX.proxy(function(){BX.cleanNode(this.loadingScreen.popupContainer),this.loadingScreen.popupContainer.appendChild(BX.create("IMG",{props:{src:this.templateFolder+"/images/loader.gif"}})),this.loadingScreen.popupContainer.removeAttribute("style"),this.loadingScreen.popupContainer.style.display="block"},this)}})),this.loadingScreen.show())},e.prototype.endLoader=function(e){this.BXFormPosting=!1,this.loadingScreen&&this.loadingScreen.isShown()&&this.loadingScreen.close(),clearTimeout(e)},e}(); /* End */ ;; /* /bitrix/templates/dresscode/components/bitrix/sale.account.pay/.default/script.min.js?17077613673463*/