(function(e){if(BX.TreeConditions)return;BX.TreeCondCtrlAtom=function(e,t,i){this.boolResult=false;if(!e||!t||!t.values)return this.boolResult;this.parentContainer=e;this.valuesContainer=t.values;if(!BX.type.isNotEmptyString(i)&&!BX.type.isPlainObject(i))return this.boolResult;if(BX.type.isNotEmptyString(i)){i={text:i,type:"string"}}if(BX.type.isPlainObject(i)){if(!BX.type.isNotEmptyString(i.type))return this.boolResult;this.arStartParams=i;this.id=null;this.name=null;this.type=i.type;this.showValue=false;if(BX.type.isNotEmptyString(i.show_value)){this.showValue=i.show_value==="Y"}if(this.type!=="string"&&this.type!=="prefix"){if(!i.id){return this.boolResult}this.id=i.id;this.name=!i.name?i.id:i.name;this.defaultText=BX.type.isNotEmptyString(i.defaultText)?i.defaultText:"...";this.defaultValue=i.defaultValue&&i.defaultValue.length>0?i.defaultValue:"";if(!this.valuesContainer[this.id]||this.valuesContainer[this.id].length===0){this.valuesContainer[this.id]=this.defaultValue}}this.boolResult=true;if(this.type==="string"||this.type==="prefix"){this.Init()}}return this.boolResult};BX.TreeCondCtrlAtom.prototype.Init=function(){if(this.boolResult){this.parentContainer=BX(this.parentContainer);if(!!this.parentContainer){if(this.type==="string"||this.type==="prefix"){this.parentContainer.appendChild(BX.create("SPAN",{props:{className:this.type==="prefix"?"control-prefix":"control-string"},html:BX.util.htmlspecialchars(this.arStartParams.text)}))}else{this.CreateLink()}}else{this.boolResult=false}}return this.boolResult};BX.TreeCondCtrlAtom.prototype.IsValue=function(){return this.valuesContainer[this.id]&&this.valuesContainer[this.id].length>0};BX.TreeCondCtrlAtom.prototype.InitValue=function(){return this.IsValue()};BX.TreeCondCtrlAtom.prototype.ReInitValue=function(e){if(BX.util.in_array(this.id,e)){this.InitValue()}};BX.TreeCondCtrlAtom.prototype.SetValue=function(){return this.IsValue()};BX.TreeCondCtrlAtom.prototype.View=function(e){};BX.TreeCondCtrlAtom.prototype.onChange=function(){this.SetValue();this.View(false)};BX.TreeCondCtrlAtom.prototype.onKeypress=function(t){if(!t){t=e.event}if(!!t.keyCode){switch(t.keyCode){case 13:this.onChange();break;case 27:this.InitValue();this.View(false);break}if(t.keyCode===13){return BX.PreventDefault(t)}}};BX.TreeCondCtrlAtom.prototype.onClick=function(){this.InitValue();this.View(true)};BX.TreeCondCtrlAtom.prototype.Delete=function(){if(this.type!=="string"){if(this.link){BX.unbindAll(this.link);this.link=BX.remove(this.link)}}};BX.TreeCondCtrlAtom.prototype.CreateLink=function(){if(this.boolResult){this.link=null;this.link=this.parentContainer.appendChild(BX.create("A",{props:{id:this.parentContainer.id+"_"+this.id+"_link",className:""},style:{display:""},html:this.IsValue()?BX.util.htmlspecialchars(this.valuesContainer[this.id]):this.defaultText}));if(!this.link){this.boolResult=false}}return this.boolResult};BX.TreeCondCtrlAtom.prototype.prepareData=function(e,t){var i="",s,l="",n=true;if(BX.type.isString(e)){i=e}else if(BX.type.isPlainObject(e)){for(s in e){if(e.hasOwnProperty(s)){i+=!n?"&":"";l=BX.util.urlencode(s);if(t){l=t+"["+l+"]"}if(BX.type.isPlainObject(e[s])){i+=this.prepareData(e[s],l)}else{i+=l+"="+BX.util.urlencode(e[s])}n=false}}}return i};BX.TreeCondCtrlAtom.prototype.ViewFormat=function(e,t){return this.showValue?t+" ["+e+"]":t};BX.TreeCondCtrlInput=function(e,t,i){if(BX.TreeCondCtrlInput.superclass.constructor.apply(this,arguments))this.Init();return this.boolResult};BX.extend(BX.TreeCondCtrlInput,BX.TreeCondCtrlAtom);BX.TreeCondCtrlInput.prototype.Init=function(){if(this.boolResult&&BX.TreeCondCtrlInput.superclass.Init.apply(this,arguments)){this.input=null;this.input=this.parentContainer.appendChild(BX.create("INPUT",{props:{type:"text",id:this.parentContainer.id+"_"+this.id,name:this.name,className:"",value:this.IsValue()?this.valuesContainer[this.id]:""},style:{display:"none"},events:{change:BX.proxy(this.onChange,this),blur:BX.proxy(this.onChange,this),keypress:BX.proxy(this.onKeypress,this)}}));this.boolResult=!!this.input}return this.boolResult};BX.TreeCondCtrlInput.prototype.InitValue=function(){if(BX.TreeCondCtrlInput.superclass.InitValue.apply(this,arguments)){BX.adjust(this.link,{html:BX.util.htmlspecialchars(this.valuesContainer[this.id])});this.input.value=this.valuesContainer[this.id]}else{BX.adjust(this.link,{html:this.defaultText});this.input.value=""}};BX.TreeCondCtrlInput.prototype.SetValue=function(){this.valuesContainer[this.id]=this.input.value;if(BX.TreeCondCtrlInput.superclass.SetValue.apply(this,arguments)){BX.adjust(this.link,{html:BX.util.htmlspecialchars(this.valuesContainer[this.id])})}else{BX.adjust(this.link,{html:this.defaultText})}};BX.TreeCondCtrlInput.prototype.View=function(e){BX.TreeCondCtrlInput.superclass.View.apply(this,arguments);if(e){BX.style(this.link,"display","none");BX.style(this.input,"display","");BX.focus(this.input)}else{BX.style(this.input,"display","none");BX.style(this.link,"display","");this.input.blur()}};BX.TreeCondCtrlInput.prototype.Delete=function(){BX.TreeCondCtrlInput.superclass.Delete.apply(this,arguments);if(this.input){BX.unbindAll(this.input);this.input=BX.remove(this.input)}};BX.TreeCondCtrlInput.prototype.CreateLink=function(){if(BX.TreeCondCtrlInput.superclass.CreateLink.apply(this,arguments)){BX.bind(this.link,"click",BX.proxy(this.onClick,this))}return this.boolResult};BX.TreeCondCtrlBaseSelect=function(e,t,i){this.values=[];this.labels=[];this.multiple=false;this.size=3;this.first_option="...";this.boolVisual=false;this.visual=null;if(BX.TreeCondCtrlBaseSelect.superclass.constructor.apply(this,arguments)){if(BX.type.isNotEmptyString(i.multiple))this.multiple=i.multiple==="Y";if(BX.type.isString(i.size)||BX.type.isNumber(i.size)){i.size=parseInt(i.size,10);if(!isNaN(i.size)&&i.size>0)this.size=i.size}if(BX.type.isNotEmptyString(i.first_option))this.first_option=i.first_option;this.dontShowFirstOption=!!i.dontShowFirstOption}return this.boolResult};BX.extend(BX.TreeCondCtrlBaseSelect,BX.TreeCondCtrlAtom);BX.TreeCondCtrlBaseSelect.prototype.Init=function(){BX.TreeCondCtrlInput.superclass.Init.apply(this,arguments);return this.boolResult};BX.TreeCondCtrlBaseSelect.prototype.setValueText=function(){var e,t,i;if(BX.type.isString(this.valuesContainer[this.id]))this.valuesContainer[this.id]=this.valuesContainer[this.id].split(",");e=[];this.select.selectedIndex=-1;for(t=0;t-1){this.select.options[t].selected=true;if(this.select.selectedIndex===-1){this.select.selectedIndex=t}e[e.length]=this.ViewFormat(this.values[i],this.labels[i])}else{this.select.options[t].selected=false}}else{this.select.options[t].selected=false}}if(e.length===0)e[0]=this.defaultText;BX.adjust(this.link,{html:BX.util.htmlspecialchars(e.join(", "))});e=null};BX.TreeCondCtrlBaseSelect.prototype.SetValue=function(){var e=[],t=[],i,s;if(this.multiple){for(i=0;i-1){e[e.length]=this.ViewFormat(this.values[s],this.labels[s])}}}if(e.length===0){e[0]=this.defaultText}this.valuesContainer[this.id]=t}else{if(this.select.selectedIndex>-1&&this.select.options[this.select.selectedIndex]){this.valuesContainer[this.id]=[this.select.options[this.select.selectedIndex].value];i=BX.util.array_search(this.select.options[this.select.selectedIndex].value,this.values);e[0]=i>-1?this.ViewFormat(this.values[i],this.labels[i]):this.defaultText}}if(BX.TreeCondCtrlBaseSelect.superclass.SetValue.apply(this,arguments))BX.adjust(this.link,{html:BX.util.htmlspecialchars(e.join(", "))});else BX.adjust(this.link,{html:this.defaultText})};BX.TreeCondCtrlBaseSelect.prototype.View=function(e){BX.TreeCondCtrlBaseSelect.superclass.View.apply(this,arguments);if(e){BX.style(this.link,"display","none");BX.style(this.select,"display","");BX.focus(this.select)}else{BX.style(this.select,"display","none");BX.style(this.link,"display","");this.select.blur()}};BX.TreeCondCtrlBaseSelect.prototype.onChange=function(){this.SetValue();if(!this.multiple)this.View(false);if(this.boolVisual)this.visual()};BX.TreeCondCtrlBaseSelect.prototype.onBlur=function(){this.View(false)};BX.TreeCondCtrlBaseSelect.prototype.onKeypress=function(t){if(!t)t=e.event;if(t.keyCode&&(t.keyCode===13||t.keyCode===27)){this.View(false);if(t.keyCode===13)return BX.PreventDefault(t)}};BX.TreeCondCtrlBaseSelect.prototype.onClick=function(){this.View(true)};BX.TreeCondCtrlBaseSelect.prototype.Delete=function(){BX.TreeCondCtrlBaseSelect.superclass.Delete.apply(this,arguments);if(this.select){BX.unbindAll(this.select);this.select=BX.remove(this.select)}if(this.boolVisual)this.visual=null};BX.TreeCondCtrlBaseSelect.prototype.CreateLink=function(){if(BX.TreeCondCtrlBaseSelect.superclass.CreateLink.apply(this,arguments))BX.bind(this.link,"click",BX.proxy(this.onClick,this));return this.boolResult};BX.TreeCondCtrlBaseSelect.prototype.CreateSelect=function(){var e;e={id:this.parentContainer.id+"_"+this.id,name:this.name,className:"",selectedIndex:-1};if(this.multiple){e.name=this.name+"[]";e.multiple=true;e.size=this.size}this.select=this.parentContainer.appendChild(BX.create("select",{props:e,style:{display:"none"},events:{change:BX.proxy(this.onChange,this),blur:BX.proxy(this.onBlur,this),keypress:BX.proxy(this.onKeypress,this)}}));if(BX.type.isElementNode(this.select)){if(!this.multiple&&!this.dontShowFirstOption){this.select.appendChild(BX.create("option",{props:{value:""},html:this.first_option}))}}e=null};BX.TreeCondCtrlSelect=function(e,t,i){var s;if(BX.TreeCondCtrlSelect.superclass.constructor.apply(this,arguments)){if(!BX.type.isPlainObject(i.values)){return this.boolResult}for(s in i.values){if(i.values.hasOwnProperty(s)){this.values[this.values.length]=s;this.labels[this.labels.length]=i.values[s]}}if(this.values.length===0){return this.boolResult}if(this.defaultValue.length>0){s=BX.util.array_search(this.defaultValue,this.values);this.defaultText=s>-1?this.labels[s]:""}if(BX.type.isPlainObject(i.events)&&BX.type.isFunction(i.events.visual)){this.boolVisual=true;this.visual=i.events.visual}this.Init()}return this.boolResult};BX.extend(BX.TreeCondCtrlSelect,BX.TreeCondCtrlBaseSelect);BX.TreeCondCtrlSelect.prototype.Init=function(){var e;if(this.boolResult&&BX.TreeCondCtrlSelect.superclass.Init.apply(this,arguments)){this.CreateSelect();if(BX.type.isElementNode(this.select)){for(e in this.values){if(this.values.hasOwnProperty(e)){this.select.appendChild(BX.create("option",{props:{value:this.values[e]},html:BX.util.htmlspecialchars(this.ViewFormat(this.values[e],this.labels[e]))}))}}this.InitValue()}this.boolResult=!!this.select}return this.boolResult};BX.TreeCondCtrlSelect.prototype.InitValue=function(){if(BX.TreeCondCtrlSelect.superclass.InitValue.apply(this,arguments))this.setValueText();else this.select.selectedIndex=-1};BX.TreeCondCtrlSelect.prototype.CreateLink=function(){if(BX.TreeCondCtrlSelect.superclass.CreateLink.apply(this,arguments))BX.bind(this.link,"click",BX.proxy(this.onClick,this));return this.boolResult};BX.TreeCondCtrlLazySelect=function(e,t,i){var s;this.loaded=false;this.loadProgress=false;this.loadUrl="";this.loadUrlParams={};if(BX.TreeCondCtrlLazySelect.superclass.constructor.apply(this,arguments)){if(BX.type.isNotEmptyString(i.load_url))this.loadUrl=i.load_url;if(BX.type.isPlainObject(i.load_params)){for(s in i.load_params){if(i.load_params.hasOwnProperty(s))this.loadUrlParams[s]=i.load_params[s]}}this.Init()}return this.boolResult};BX.extend(BX.TreeCondCtrlLazySelect,BX.TreeCondCtrlBaseSelect);BX.TreeCondCtrlLazySelect.prototype.Init=function(){if(this.boolResult&&BX.TreeCondCtrlLazySelect.superclass.Init.apply(this,arguments)){this.CreateSelect();this.InitValue()}return this.boolResult};BX.TreeCondCtrlLazySelect.prototype.InitValue=function(){if(BX.TreeCondCtrlLazySelect.superclass.InitValue.apply(this,arguments)){if(!this.loaded)this.ajaxLoad("InitValue");else this.setValueText()}else{this.select.selectedIndex=-1}};BX.TreeCondCtrlLazySelect.prototype.ajaxLoad=function(e){var t={},i,s;if(this.loaded||this.loadProgress)return;for(i in this.loadUrlParams){if(this.loadUrlParams.hasOwnProperty(i))t[i]=this.loadUrlParams[i]}t.sessid=BX.bitrix_sessid();t.lang=BX.message("LANGUAGE_ID");switch(e){default:case"InitValue":s=BX.proxy(this.ajaxLoadResultFromInit,this);break;case"onClick":s=BX.proxy(this.ajaxLoadResultFromClick,this);break}this.loadProgress=true;BX.showWait(this.parentContainer);BX.ajax({method:"POST",dataType:"json",url:this.loadUrl,data:t,onsuccess:s});s=null;t=null};BX.TreeCondCtrlLazySelect.prototype.ajaxLoadResult=function(e){var t;this.loadProgress=false;BX.closeWait(this.parentContainer);if(BX.type.isArray(e)){for(t=0;t0?this.valuesContainer[this.id]:this.defaultText}this.Init()}return this.boolResult};BX.extend(BX.TreeCondCtrlPopup,BX.TreeCondCtrlAtom);BX.TreeCondCtrlPopup.prototype.Init=function(){if(this.boolResult&&BX.TreeCondCtrlPopup.superclass.Init.apply(this,arguments)){if(this.popup_param_id){this.popup_params[this.popup_param_id]=this.parentContainer.id+"_"+this.id}this.input=this.parentContainer.appendChild(BX.create("INPUT",{props:{type:"hidden",id:this.parentContainer.id+"_"+this.id,name:this.name,className:"",value:this.IsValue()?this.valuesContainer[this.id]:""},style:{display:"none"},events:{change:BX.proxy(this.onChange,this)}}));this.boolResult=!!this.input}return this.boolResult};BX.TreeCondCtrlPopup.prototype.CreateLink=function(){if(this.boolResult){this.link=this.parentContainer.appendChild(BX.create("A",{props:{id:this.parentContainer.id+"_"+this.id+"_link",className:""},style:{display:""},html:this.IsValue()?BX.util.htmlspecialchars(this.ViewFormat(this.valuesContainer[this.id],this.label)):this.defaultText,events:{click:BX.proxy(this.PopupShow,this)}}));this.boolResult=!!this.link}return this.boolResult};BX.TreeCondCtrlPopup.prototype.PopupShow=function(){var t=this.popup_url,i=this.prepareData(this.popup_params);if(i.length>0){t+=(t.indexOf("?")!==-1?"&":"?")+i}var s=e.open(t,"","scrollbars=yes,resizable=yes,width=900,height=600,top="+parseInt((screen.height-500)/2-14,10)+",left="+parseInt((screen.width-600)/2-5,10));s.onbeforeunload=function(){BX.onCustomEvent("onTreeCondPopupClose")}};BX.TreeCondCtrlPopup.prototype.onChange=function(){this.valuesContainer[this.id]=this.input.value};BX.TreeCondCtrlPopup.prototype.Delete=function(){BX.TreeCondCtrlPopup.superclass.Delete.apply(this,arguments);if(this.input){BX.unbindAll(this.input);this.input=BX.remove(this.input)}};BX.TreeUserCondCtrlPopup=function(e,t,i){var s;if(BX.TreeUserCondCtrlPopup.superclass.constructor.apply(this,arguments)){if(!i.popup_url){return this.boolResult}this.coreUserInfo=BX.type.isNotEmptyString(i.coreUserInfo)&&i.coreUserInfo==="Y";this.user_load_url=i.user_load_url||"";this.popup_url=i.popup_url;if(i.popup_params){for(s in i.popup_params){if(i.popup_params.hasOwnProperty(s)){this.popup_params[s]=i.popup_params[s]}}}this.popup_param_id=null;if(BX.type.isNotEmptyString(i.param_id)){this.popup_param_id=i.param_id}this.label="";if(!!t.labels&&!!t.labels[this.id]){this.label=t.labels[this.id]}if(this.label.length===0){this.label=this.valuesContainer[this.id].length>0?this.valuesContainer[this.id]:this.defaultText}}return this.boolResult};BX.extend(BX.TreeUserCondCtrlPopup,BX.TreeCondCtrlPopup);BX.TreeUserCondCtrlPopup.prototype.Init=function(){var e;this.inputs=[];if(this.valuesContainer[this.id]===""){this.valuesContainer[this.id]=[];this.label=[]}if(!BX.type.isArray(this.valuesContainer[this.id])){this.valuesContainer[this.id]=[this.valuesContainer[this.id]];this.label=[this.label]}if(this.boolResult&&BX.TreeUserCondCtrlPopup.superclass.Init.apply(this,arguments)){if(this.input){BX.unbindAll(this.input);this.input=BX.remove(this.input)}if(this.popup_param_id){this.popup_params[this.popup_param_id]=this.parentContainer.id+"_"+this.id}if(!this.IsValue()){this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]","")}else{for(e in this.valuesContainer[this.id]){if(!this.valuesContainer[this.id].hasOwnProperty(e))continue;this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",this.valuesContainer[this.id][e])}}this.AppendFakeInputNode(this.parentContainer.id+"_"+this.id,this.name);this.boolResult=!!this.inputs}return this.boolResult};BX.TreeUserCondCtrlPopup.prototype.CreateLink=function(){this.popup_params["FN"]="sale_discount_form";this.popup_params["FC"]="fake_"+this.name;var e;if(this.boolResult){this.defaultLabel=BX.create("SPAN",{text:this.defaultText,style:{cursor:"pointer"},props:{className:"condition-dots"}});this.link=this.parentContainer.appendChild(BX.create("SPAN",{props:{id:this.parentContainer.id+"_"+this.id+"_link",className:"condition-list-wrap"},style:{display:""},events:{click:BX.proxy(this.PopupShow,this)},children:[this.defaultLabel]}));for(e in this.valuesContainer[this.id]){if(!this.valuesContainer[this.id].hasOwnProperty(e))continue;this.AppendItemNode(this.valuesContainer[this.id][e],this.label[e])}this.boolResult=!!this.link}return this.boolResult};BX.TreeUserCondCtrlPopup.prototype.AppendItemNode=function(e,t){this.link.insertBefore(BX.create("SPAN",{props:{className:"condition-item"},style:{display:""},children:[BX.create("SPAN",{props:{className:"condition-item-text"},html:BX.util.htmlspecialchars(this.ViewFormat(e,t))}),BX.create("SPAN",{props:{className:"condition-item-del"},attrs:{"bx-data-value":e},events:{click:BX.proxy(this.DeleteItem,this)}})]}),this.defaultLabel)};BX.TreeUserCondCtrlPopup.prototype.AppendInputNode=function(e,t,i){this.inputs.push(this.parentContainer.appendChild(BX.create("INPUT",{props:{type:"hidden",id:e,name:t,value:i},style:{display:"none"},events:{change:BX.proxy(this.onChange,this)}})))};BX.TreeUserCondCtrlPopup.prototype.AppendFakeInputNode=function(e,t){this.inputs.push(this.parentContainer.appendChild(BX.create("INPUT",{props:{type:"hidden",id:"fake_"+e,name:"fake_"+t},style:{display:"none"},events:{change:BX.proxy(this.onChangeFake,this)}})))};BX.TreeUserCondCtrlPopup.prototype.onChangeFake=function(e){let t=e.target.value;if(this.coreUserInfo){BX.ajax({method:"POST",dataType:"json",url:"/bitrix/tools/get_user.php",data:{sessid:BX.bitrix_sessid(),ajax:"Y",format:"Y",raw:"Y",ID:t},onsuccess:BX.proxy(this.successGetUserData,this)})}else{BX.ajax({method:"POST",dataType:"json",url:this.user_load_url,data:{sessid:BX.bitrix_sessid(),AJAX_ACTION:"getUserName",USER_ID:t},onsuccess:BX.delegate((function(e){this.setUserData(t,e.name)}),this)})}};BX.TreeUserCondCtrlPopup.prototype.successGetUserData=function(e){if(!BX.type.isPlainObject(e)){return}this.setUserData(e.ID,e.NAME)};BX.TreeUserCondCtrlPopup.prototype.setUserData=function(e,t){this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",e);this.AppendItemNode(e,t);this.valuesContainer[this.id].push(e)};BX.TreeUserCondCtrlPopup.prototype.onSave=function(e){if(BX.type.isPlainObject(e)){this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",e.id);this.AppendItemNode(e.id,e.name);this.valuesContainer[this.id].push(e.id)}};BX.TreeUserCondCtrlPopup.prototype.DeleteItem=function(e){var t=e.target||e.srcElement;if(!t){BX.PreventDefault(e);return}var i=BX.findParent(t,{className:"condition-item",tagName:"span"},3);if(!i){BX.PreventDefault(e);return}BX.remove(BX.findParent(t,{className:"condition-item",tagName:"span"},3));BX.remove(BX.findChild(this.parentContainer,{tagName:"input",attribute:{name:this.name+"[]",value:t.getAttribute("bx-data-value")}},3));BX.PreventDefault(e)};BX.TreeUserCondCtrlPopup.prototype.Delete=function(){BX.TreeUserCondCtrlPopup.superclass.Delete.apply(this,arguments);if(this.input){BX.unbindAll(this.input);this.input=BX.remove(this.input)}if(this.inputs){for(var e in this.inputs){if(!this.inputs.hasOwnProperty(e))continue;BX.unbindAll(this.inputs[e]);BX.remove(this.inputs[e]);delete this.inputs[e]}this.inputs=[]}if(!!this.dialog){this.dialog=null}};BX.TreeCondCtrlDialog=function(e,t,i){var s;if(BX.TreeCondCtrlDialog.superclass.constructor.apply(this,arguments)){this.popup_params.event="onTreeCondDialogSave";s=this.prepareData(this.popup_params);if(s.length>0){this.popup_url+=(this.popup_url.indexOf("?")!==-1?"&":"?")+s}this.dialog=null}return this.boolResult};BX.extend(BX.TreeCondCtrlDialog,BX.TreeCondCtrlPopup);BX.TreeCondCtrlDialog.prototype.CreateLink=function(){if(this.boolResult){this.link=this.parentContainer.appendChild(BX.create("A",{props:{id:this.parentContainer.id+"_"+this.id+"_link",className:""},style:{display:""},html:this.IsValue()?BX.util.htmlspecialchars(this.ViewFormat(this.valuesContainer[this.id],this.label)):this.defaultText,events:{click:BX.proxy(this.DialogShow,this)}}));this.boolResult=!!this.link}return this.boolResult};BX.TreeCondCtrlDialog.prototype.onChange=function(){this.valuesContainer[this.id]=this.input.value};BX.TreeCondCtrlDialog.prototype.DialogShow=function(){if(this.dialog!==null)this.dialog=null;this.dialog=new BX.CAdminDialog({content_url:this.popup_url,height:Math.max(500,e.innerHeight-400),width:Math.max(800,e.innerWidth-400),draggable:true,resizable:true,min_height:500,min_width:800});if(!!this.dialog){BX.addCustomEvent("onTreeCondDialogSave",BX.proxy(this.onSave,this));this.dialog.Show()}};BX.TreeCondCtrlDialog.prototype.onSave=function(e){BX.removeCustomEvent("onTreeCondDialogSave",BX.proxy(this.onSave,this));if(BX.type.isPlainObject(e)){this.input.value=e.id;this.link.innerHTML=BX.util.htmlspecialchars(this.ViewFormat(e.id,e.name));this.onChange()}this.dialog.Close();this.dialog=null};BX.TreeCondCtrlDialog.prototype.Delete=function(){BX.TreeCondCtrlDialog.superclass.Delete.apply(this,arguments);if(this.input){BX.unbindAll(this.input);this.input=BX.remove(this.input)}if(!!this.dialog){this.dialog=null}};BX.TreeMultiCondCtrlDialog=function(e,t,i){this.defaultLabel=null;var s;if(BX.TreeMultiCondCtrlDialog.superclass.constructor.apply(this,arguments)){this.popup_params.event="onTreeCondDialogSave";s=this.prepareData(this.popup_params);if(s.length>0){this.popup_url+=(this.popup_url.indexOf("?")!==-1?"&":"?")+s}this.dialog=null;BX.addClass(e,"condition-multi")}return this.boolResult};BX.extend(BX.TreeMultiCondCtrlDialog,BX.TreeCondCtrlPopup);BX.TreeMultiCondCtrlDialog.prototype.AppendItemNode=function(e,t){this.link.insertBefore(BX.create("SPAN",{props:{className:"condition-item"},style:{display:""},children:[BX.create("SPAN",{props:{className:"condition-item-text"},html:BX.util.htmlspecialchars(this.ViewFormat(e,t))}),BX.create("SPAN",{props:{className:"condition-item-del"},attrs:{"bx-data-value":e},events:{click:BX.proxy(this.DeleteItem,this)}})]}),this.defaultLabel)};BX.TreeMultiCondCtrlDialog.prototype.AppendInputNode=function(e,t,i){this.inputs.push(this.parentContainer.appendChild(BX.create("INPUT",{props:{type:"hidden",id:e,name:t,value:i},style:{display:"none"},events:{change:BX.proxy(this.onChange,this)}})))};BX.TreeMultiCondCtrlDialog.prototype.Init=function(){var e;this.inputs=[];if(this.valuesContainer[this.id]===""){this.valuesContainer[this.id]=[];this.label=[]}if(!BX.type.isArray(this.valuesContainer[this.id])){this.valuesContainer[this.id]=[this.valuesContainer[this.id]];this.label=[this.label]}if(this.boolResult&&BX.TreeMultiCondCtrlDialog.superclass.Init.apply(this,arguments)){if(this.input){BX.unbindAll(this.input);this.input=BX.remove(this.input)}if(this.popup_param_id){this.popup_params[this.popup_param_id]=this.parentContainer.id+"_"+this.id}if(!this.IsValue()){this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]","")}else{for(e in this.valuesContainer[this.id]){if(!this.valuesContainer[this.id].hasOwnProperty(e))continue;this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",this.valuesContainer[this.id][e])}}this.boolResult=!!this.inputs}return this.boolResult};BX.TreeMultiCondCtrlDialog.prototype.CreateLink=function(){var e;if(this.boolResult){this.defaultLabel=BX.create("SPAN",{text:this.defaultText,style:{cursor:"pointer"},props:{className:"condition-dots"}});this.link=this.parentContainer.appendChild(BX.create("SPAN",{props:{id:this.parentContainer.id+"_"+this.id+"_link",className:"condition-list-wrap"},style:{display:""},events:{click:BX.proxy(this.DialogShow,this)},children:[this.defaultLabel]}));for(e in this.valuesContainer[this.id]){if(!this.valuesContainer[this.id].hasOwnProperty(e))continue;this.AppendItemNode(this.valuesContainer[this.id][e],this.label[e])}this.boolResult=!!this.link}return this.boolResult};BX.TreeMultiCondCtrlDialog.prototype.onChange=function(){};BX.TreeMultiCondCtrlDialog.prototype.DialogShow=function(){if(this.dialog!==null)this.dialog=null;this.dialog=new BX.CAdminDialog({content_url:this.popup_url,height:Math.max(500,e.innerHeight-400),width:Math.max(800,e.innerWidth-400),draggable:true,resizable:true,min_height:500,min_width:800});if(!!this.dialog){BX.addCustomEvent("onTreeCondDialogSave",BX.proxy(this.onSave,this));BX.addCustomEvent(this.dialog,"onWindowClose",BX.delegate((function(){BX.removeCustomEvent("onTreeCondDialogSave",BX.proxy(this.onSave,this))}),this));this.dialog.Show()}};BX.TreeMultiCondCtrlDialog.prototype.onSave=function(e){if(BX.type.isPlainObject(e)){this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",e.id);this.AppendItemNode(e.id,e.name);this.valuesContainer[this.id].push(e.id)}};BX.TreeMultiCondCtrlDialog.prototype.DeleteItem=function(e){var t=e.target||e.srcElement;if(!t){BX.PreventDefault(e);return}var i=BX.findParent(t,{className:"condition-item",tagName:"span"},3);if(!i){BX.PreventDefault(e);return}BX.remove(BX.findParent(t,{className:"condition-item",tagName:"span"},3));BX.remove(BX.findChild(this.parentContainer,{tagName:"input",attribute:{name:this.name+"[]",value:t.getAttribute("bx-data-value")}},3));BX.PreventDefault(e)};BX.TreeMultiCondCtrlDialog.prototype.Delete=function(){BX.TreeMultiCondCtrlDialog.superclass.Delete.apply(this,arguments);if(this.input){BX.unbindAll(this.input);this.input=BX.remove(this.input)}if(this.inputs){for(var e in this.inputs){if(!this.inputs.hasOwnProperty(e))continue;BX.unbindAll(this.inputs[e]);BX.remove(this.inputs[e]);delete this.inputs[e]}this.inputs=[]}if(!!this.dialog){this.dialog=null}};BX.TreeCondCtrlDateTime=function(e,t,i){if(BX.TreeCondCtrlDateTime.superclass.constructor.apply(this,arguments)){this.format=!!i.format&&i.format==="date"?"date":"datetime";this.Init()}return this.boolResult};BX.extend(BX.TreeCondCtrlDateTime,BX.TreeCondCtrlAtom);BX.TreeCondCtrlDateTime.prototype.Init=function(){if(this.boolResult&&BX.TreeCondCtrlDateTime.superclass.Init.apply(this,arguments)){this.input=BX.create("INPUT",{props:{type:"text",id:this.parentContainer.id+"_"+this.id,name:this.name,className:"adm-input",value:this.IsValue()?this.valuesContainer[this.id]:""},events:{change:BX.proxy(this.onChange,this),keypress:BX.proxy(this.onKeypress,this)}});this.icon=BX.create("SPAN",{props:{id:this.parentContainer.id+"_"+this.id+"_icon",className:"adm-calendar-icon",title:BX.message("JC_CORE_TREE_CONTROL_DATETIME_ICON")},events:{click:BX.proxy(this.ShowCalendarControl,this)}});this.calendarText=BX.create("DIV",{props:{className:"adm-input-wrap"},children:[this.input,this.icon]});this.calendar=this.parentContainer.appendChild(BX.create("DIV",{props:{id:this.parentContainer.id+"_"+this.id+"_calendar",className:"adm-calendar-block adm-filter-alignment"},style:{display:"none",verticalAlign:"middle"},children:[BX.create("DIV",{props:{className:"adm-filter-box-sizing"},style:{verticalAlign:"middle"},children:[this.calendarText]})]}));this.boolResult=!!this.calendar}};BX.TreeCondCtrlDateTime.prototype.InitValue=function(){if(BX.TreeCondCtrlDateTime.superclass.InitValue.apply(this,arguments)){BX.adjust(this.link,{html:BX.util.htmlspecialchars(this.valuesContainer[this.id])});this.input.value=this.valuesContainer[this.id]}else{BX.adjust(this.link,{html:this.defaultText});this.input.value=""}};BX.TreeCondCtrlDateTime.prototype.SetValue=function(){this.valuesContainer[this.id]=this.input.value;if(BX.TreeCondCtrlDateTime.superclass.SetValue.apply(this,arguments)){BX.adjust(this.link,{html:BX.util.htmlspecialchars(this.valuesContainer[this.id])})}else{BX.adjust(this.link,{html:this.defaultText})}};BX.TreeCondCtrlDateTime.prototype.View=function(e){BX.TreeCondCtrlDateTime.superclass.View.apply(this,arguments);if(e){BX.style(this.link,"display","none");BX.style(this.calendar,"display","inline-block");BX.focus(this.input)}else{BX.style(this.calendar,"display","none");BX.style(this.link,"display","")}};BX.TreeCondCtrlDateTime.prototype.Delete=function(){BX.TreeCondCtrlDateTime.superclass.Delete.apply(this,arguments);if(!!this.input){BX.unbindAll(this.input);this.input=BX.remove(this.input)}if(!!this.icon){BX.unbindAll(this.icon);this.icon=BX.remove(this.icon)}if(!!this.calendarText){this.calendarText=BX.remove(this.calendarText)}if(!!this.calendar){BX.unbindAll(this.calendar);this.calendar=BX.remove(this.calendar)}};BX.TreeCondCtrlDateTime.prototype.CreateLink=function(){if(BX.TreeCondCtrlDateTime.superclass.CreateLink.apply(this,arguments)){BX.bind(this.link,"click",BX.proxy(this.onClick,this))}return this.boolResult};BX.TreeCondCtrlDateTime.prototype.ShowCalendarControl=function(){if(!!this.calendarText){BX.calendar({node:this.calendarText,field:this.input,form:"",bTime:this.format==="datetime",bHideTime:false})}};BX.TreeConditions=function(e,t,i){var s;BX.onCustomEvent("onTreeConditionsInit",[e,t,i]);this.boolResult=false;if(!e||typeof e!=="object"||!e.parentContainer){return this.boolResult}this.parentContainer=e.parentContainer;if(!e.form&&!e.formName){return this.boolResult}this.arStartParams=e;this.form=!!e.form?e.form:null;this.formName=!!e.formName?e.formName:null;this.mess=null;if(BX.type.isPlainObject(e.mess)){this.mess=e.mess;BX.message(this.mess)}this.messTree={SELECT_CONTROL:BX.message("JC_CORE_TREE_SELECT_CONTROL"),ADD_CONTROL:BX.message("JC_CORE_TREE_ADD_CONTROL"),DELETE_CONTROL:BX.message("JC_CORE_TREE_DELETE_CONTROL"),CONTROL_DATETIME_ICON:BX.message("JC_CORE_TREE_CONTROL_DATETIME_ICON"),CONDITION_ERROR:BX.message("JC_CORE_TREE_CONDITION_ERROR"),CONDITION_FATAL_ERROR:BX.message("JC_CORE_TREE_CONDITION_FATAL_ERROR")};if(BX.type.isPlainObject(e.messTree)){for(s in e.messTree){if(e.messTree.hasOwnProperty(s)){this.messTree[s]=e.messTree[s]}}}this.sepID=!!e.sepID?e.sepID:"__";this.sepName=!!e.sepName?e.sepName:this.sepID;this.prefix=!!e.prefix?e.prefix:"rule";this.AtomTypes={prefix:BX.TreeCondCtrlAtom,input:BX.TreeCondCtrlInput,select:BX.TreeCondCtrlSelect,lazySelect:BX.TreeCondCtrlLazySelect,popup:BX.TreeCondCtrlPopup,userPopup:BX.TreeUserCondCtrlPopup,datetime:BX.TreeCondCtrlDateTime,dialog:BX.TreeCondCtrlDialog,multiDialog:BX.TreeMultiCondCtrlDialog};if(!!e.atomtypes&&typeof e.atomtypes==="object"){for(s in e.atomtypes){if(!e.atomtypes.hasOwnProperty(s)||!!this.AtomTypes[s])continue;this.AtomTypes[s]=e.atomtypes[s]}}if(!t||typeof t!=="object"){return this.boolResult}this.tree=t;if(!i||!BX.type.isArray(i)){return this.boolResult}this.controls=i;this.boolResult=true;BX.ready(BX.delegate(this.RenderTree,this));return this.boolResult};BX.TreeConditions.prototype.Delete=function(){if(this.tree){this.DeleteLevel(this.tree)}};BX.TreeConditions.prototype.ControlSearch=function(e){var t=false,i;if(this.boolResult&&!!this.controls){for(i=0;i0){if(!!i.visual&&typeof i.visual==="object"){B=this.SearchVisual(i);if(-1-1;s--){if(!!t.children[s]){i.indexPrev=s;break}}}}}}}return i};BX.TreeConditions.prototype.SearchForCreateLogic=function(e,t){var i=-1,s;if(!!e&&!!e.children){if(!!e.visual&&typeof e.visual==="object"){if(t===undefined||t===null){t=e.children.length-1}for(s=t-1;s>-1;s--){if(!!e.children[s]){i=s;break}}}}return i};BX.TreeConditions.prototype.DeleteLevel=function(e,t){var i,s;if(!!e){if(!!e.children){if(e.children.length>0){for(i=0;i0){for(i=0;i0){for(r=0;r0)return false;if(e.length===0)return true;for(var t in e){if(hasOwnProperty.call(e,t))return false}return true};if(e.children&&!s(e.children)){BX.hide(e.addBtn)}}return this.boolResult};BX.TreeConditions.prototype.RenderDeleteBtn=function(e,t,i){var s;if(this.boolResult){if(!!e.container){s=e.container.appendChild(BX.create("DIV",{props:{id:e.id+"_del",className:"condition-delete",title:BX.type.isPlainObject(i.mess)&&BX.type.isNotEmptyString(i.mess.DELETE_CONTROL)?i.mess.DELETE_CONTROL:this.messTree.DELETE_CONTROL}}));if(!!s){e.delBtn=s;BX.bind(s,"click",BX.delegate((function(){this.DeleteLevel(e,t)}),this));BX.bind(e.container,"mouseover",BX.delegate((function(e){BX.style(s,"display","block");return BX.eventCancelBubble(e)}),this));BX.bind(e.container,"mouseout",BX.delegate((function(e){BX.style(s,"display","none");return BX.eventCancelBubble(e)}),this))}else{this.boolResult=false}}else{this.boolResult=false}}return this.boolResult};BX.TreeConditions.prototype.CreateLogic=function(e,t,i){var s,l;if(this.boolResult){if(!!e.logic&&typeof e.logic==="object"){this.boolResult=this.UpdateLogic(e,i)}else{l="condition-logic";if(!!i.style){l=l.concat(" ",i.style)}s=BX.create("DIV",{props:{className:l},style:{zIndex:parseInt(BX.style(e.wrapper,"z-index"),10)+1},html:i.message});if(!!s){e.wrapper.insertBefore(s,e.wrapper.childNodes[0]);e.logic=s;BX.bind(e.logic,"click",i.visual)}else{this.boolResult=false}}}return this.boolResult};BX.TreeConditions.prototype.DeleteLogic=function(e){if(this.boolResult&&!!e.logic&&typeof e.logic==="object"){BX.unbindAll(e.logic);e.logic=BX.remove(e.logic)}return this.boolResult};BX.TreeConditions.prototype.UpdateLogic=function(e,t){var i;if(this.boolResult&&!!e.logic&&typeof e.logic==="object"){i="condition-logic";if(!!t.style)i=i.concat(" ",t.style);BX.adjust(e.logic,{props:{className:i},html:t.message})}return this.boolResult};BX.TreeConditions.prototype.SearchVisual=function(e){var t=-1,i,s,l,n,o,r,a;if(this.boolResult&&!!e.visual&&typeof e.visual==="object"){if(!!e.visual.controls){i={};for(l in e.visual.controls){if(e.visual.controls.hasOwnProperty(l)){s=e.visual.controls[l];i[s]=e.values[s]}}if(!!e.visual.values){for(n=0;n=e.visual.logic.length)t=0;i=e.visual.values[t];for(l in i){if(i.hasOwnProperty(l))e.values[l]=i[l]}for(s=0;s