text: BX.namespace("BX.Mobile.Crm.Lead.Edit");BX.Mobile.Crm.Lead.Edit={ajaxPath:"",formActionUrl:"",formId:"",leadViewPath:"",mode:"",products:[],productDataFieldName:"",productsContainerNode:"",pageIdProductSelectorBack:"crmLeadEditPage",init:function(e){if(e&&typeof e==="object"){this.ajaxPath=e.ajaxPath||"";this.formActionUrl=e.formActionUrl||"";this.formId=e.formId||"";this.leadViewPath=e.leadViewPath||"";this.mode=e.mode||"";this.products=e.products||[];this.productDataFieldName=e.productDataFieldName||"";this.productsContainerNode=document.querySelector("[data-role='mobile-crm-lead-edit-products']")||"";this.pageIdProductSelectorBack=e.pageIdProductSelectorBack||"crmLeadEditPage"}if(this.mode=="EDIT"||this.mode=="CREATE"){app.setPageID(this.pageIdProductSelectorBack)}if(this.mode=="EDIT"){BXMobileApp.addCustomEvent("onCrmLeadEditUpdate",BX.proxy(function(e){if(e.formId==this.formId){BXMobileApp.UI.Page.reload()}},this))}if(this.mode=="VIEW"){BXMobileApp.addCustomEvent("onCrmLeadViewUpdate",BX.proxy(function(e){if(e.formId==this.formId){BXMobileApp.UI.Page.reload()}},this));BX.addCustomEvent("onSubmitAjaxSuccess",BX.proxy(function(e){if(e.formId==this.formId)BXMobileApp.onCustomEvent("onCrmLeadEditUpdate",{formId:this.formId},true)},this))}BX.addCustomEvent("onCrmLeadDetailDelete",function(){BXMobileApp.onCustomEvent("onCrmLeadListUpdate",{},true);BXMobileApp.UI.Page.close({drop:true})});if(this.mode=="VIEW"){BXMobileApp.addCustomEvent("onSubmitForm",BX.proxy(function(e,t,o){if(e.formId==this.formId){if(o.checked==false||!o.hasAttribute("checked")){var i=BX.create("INPUT",{attrs:{type:"hidden",name:o.name,value:""}});o.parentNode.insertBefore(i,o)}}},this));BX.addCustomEvent("onSubmitAjaxSuccess",BX.proxy(function(e){if(e.hasOwnProperty("formId")&&e.formId==this.formId){BXMobileApp.onCustomEvent("onCrmLeadListUpdate",{},true)}},this))}if(this.mode=="VIEW"||this.mode=="EDIT"){var t=BX.delegate(function(e,t,o){if(e==this.formId&&o){BX.addCustomEvent(o,"onChange",BX.proxy(this.onChange,this))}},this);BX.addCustomEvent("onInitialized",t);var o=BX.Mobile.Grid.Form.getByFormId(this.formId);t(this.formId,"",o)}},onChange:function(e,t,o){if(t&&t.name&&t.name=="CURRENCY_ID"){if(typeof BX.Mobile.Crm.ProductEditor=="object"&&BX.Mobile.Crm.ProductEditor){var i=BX.Mobile.Crm.ProductEditor;var d=t.value;i.setCurrencyId(d)}}},submit:function(){BXMobileApp.UI.Page.LoadingScreen.show();var e=BX(this.formId);if(e){var t={save:"Y",sessid:BX.bitrix_sessid()};if(BX.Mobile.Crm.ProductEditor&&BX.Mobile.Crm.ProductEditor.products){t[this.productDataFieldName]=BX.Mobile.Crm.ProductEditor.products}BX.Mobile.Crm.Detail.collectInterfaceFormData(e,t);BX.ajax({method:"POST",dataType:"json",url:this.formActionUrl,data:t,onsuccess:BX.proxy(function(e){if(e.error){app.alert({text:e.error})}else{if(this.mode=="EDIT"){BXMobileApp.onCustomEvent("onCrmLeadListUpdate",{},true);BXMobileApp.onCustomEvent("onCrmLeadViewUpdate",{formId:this.formId},true);app.closeModalDialog({cache:false})}if(this.mode=="CREATE"){var t=this.leadViewPath.replace("#lead_id#",e.itemId);BXMobileApp.onCustomEvent("onCrmLeadLoadPageBlank",{path:t},true);app.closeModalDialog({cache:false})}}BXMobileApp.UI.Page.LoadingScreen.hide()},this)})}}};
  //# sourceMappingURL=script.map.js