Your IP : 18.218.113.187


Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/aspro.allcorp3/
Upload File :
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/aspro.allcorp3/core_tree.min.js

!function(window){BX.AsTreeConditions||(BX.AsTreeCondCtrlAtom=function(parentContainer,state,arParams){if(this.boolResult=!1,!parentContainer||!state||!state.values)return this.boolResult;if(this.parentContainer=parentContainer,this.valuesContainer=state.values,!BX.type.isNotEmptyString(arParams)&&!BX.type.isPlainObject(arParams))return this.boolResult;if(BX.type.isNotEmptyString(arParams)&&(arParams={text:arParams,type:"string"}),BX.type.isPlainObject(arParams)){if(!BX.type.isNotEmptyString(arParams.type))return this.boolResult;if(this.arStartParams=arParams,this.id=null,this.name=null,this.type=arParams.type,this.showValue=!1,BX.type.isNotEmptyString(arParams.show_value)&&(this.showValue="Y"===arParams.show_value),"string"!==this.type&&"prefix"!==this.type){if(!arParams.id)return this.boolResult;this.id=arParams.id,this.name=arParams.name?arParams.name:arParams.id,this.defaultText=BX.type.isNotEmptyString(arParams.defaultText)?arParams.defaultText:"...",this.defaultValue=arParams.defaultValue&&arParams.defaultValue.length>0?arParams.defaultValue:"",this.valuesContainer[this.id]&&0!==this.valuesContainer[this.id].length||(this.valuesContainer[this.id]=this.defaultValue)}this.boolResult=!0,"string"!==this.type&&"prefix"!==this.type||this.Init()}return this.boolResult},BX.AsTreeCondCtrlAtom.prototype.Init=function(){return this.boolResult&&(this.parentContainer=BX(this.parentContainer),this.parentContainer?"string"===this.type||"prefix"===this.type?this.parentContainer.appendChild(BX.create("SPAN",{props:{className:"prefix"===this.type?"control-prefix":"control-string"},html:BX.util.htmlspecialchars(this.arStartParams.text)})):this.CreateLink():this.boolResult=!1),this.boolResult},BX.AsTreeCondCtrlAtom.prototype.IsValue=function(){return this.valuesContainer[this.id]&&this.valuesContainer[this.id].length>0},BX.AsTreeCondCtrlAtom.prototype.InitValue=function(){return this.IsValue()},BX.AsTreeCondCtrlAtom.prototype.ReInitValue=function(controls){BX.util.in_array(this.id,controls)&&this.InitValue()},BX.AsTreeCondCtrlAtom.prototype.SetValue=function(){return this.IsValue()},BX.AsTreeCondCtrlAtom.prototype.View=function(boolShow){},BX.AsTreeCondCtrlAtom.prototype.onChange=function(){this.SetValue(),this.View(!1)},BX.AsTreeCondCtrlAtom.prototype.onKeypress=function(e){if(e||(e=window.event),e.keyCode){switch(e.keyCode){case 13:this.onChange();break;case 27:this.InitValue(),this.View(!1)}if(13===e.keyCode)return BX.PreventDefault(e)}},BX.AsTreeCondCtrlAtom.prototype.onClick=function(){this.InitValue(),this.View(!0)},BX.AsTreeCondCtrlAtom.prototype.Delete=function(){"string"!==this.type&&this.link&&(BX.unbindAll(this.link),this.link=BX.remove(this.link))},BX.AsTreeCondCtrlAtom.prototype.CreateLink=function(){return 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})),this.link||(this.boolResult=!1)),this.boolResult},BX.AsTreeCondCtrlAtom.prototype.prepareData=function(arData,prefix){var data="",i,name="",firstKey=!0;if(BX.type.isString(arData))data=arData;else if(BX.type.isPlainObject(arData))for(i in arData)arData.hasOwnProperty(i)&&(data+=firstKey?"":"&",name=BX.util.urlencode(i),prefix&&(name=prefix+"["+name+"]"),BX.type.isPlainObject(arData[i])?data+=this.prepareData(arData[i],name):data+=name+"="+BX.util.urlencode(arData[i]),firstKey=!1);return data},BX.AsTreeCondCtrlAtom.prototype.ViewFormat=function(value,label){return this.showValue?label+" ["+value+"]":label},BX.AsTreeCondCtrlInput=function(parentContainer,state,arParams){return BX.AsTreeCondCtrlInput.superclass.constructor.apply(this,arguments)&&this.Init(),this.boolResult},BX.extend(BX.AsTreeCondCtrlInput,BX.AsTreeCondCtrlAtom),BX.AsTreeCondCtrlInput.prototype.Init=function(){return this.boolResult&&BX.AsTreeCondCtrlInput.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),this.boolResult},BX.AsTreeCondCtrlInput.prototype.InitValue=function(){BX.AsTreeCondCtrlInput.superclass.InitValue.apply(this,arguments)?(BX.adjust(this.link,{html:BX.util.htmlspecialchars(this.valuesContainer[this.id])}),this.input.value=this.valuesContainer[this.id]):(BX.adjust(this.link,{html:this.defaultText}),this.input.value="")},BX.AsTreeCondCtrlInput.prototype.SetValue=function(){this.valuesContainer[this.id]=this.input.value,BX.AsTreeCondCtrlInput.superclass.SetValue.apply(this,arguments)?BX.adjust(this.link,{html:BX.util.htmlspecialchars(this.valuesContainer[this.id])}):BX.adjust(this.link,{html:this.defaultText})},BX.AsTreeCondCtrlInput.prototype.View=function(boolShow){BX.AsTreeCondCtrlInput.superclass.View.apply(this,arguments),boolShow?(BX.style(this.link,"display","none"),BX.style(this.input,"display",""),BX.focus(this.input)):(BX.style(this.input,"display","none"),BX.style(this.link,"display",""),this.input.blur())},BX.AsTreeCondCtrlInput.prototype.Delete=function(){BX.AsTreeCondCtrlInput.superclass.Delete.apply(this,arguments),this.input&&(BX.unbindAll(this.input),this.input=BX.remove(this.input))},BX.AsTreeCondCtrlInput.prototype.CreateLink=function(){return BX.AsTreeCondCtrlInput.superclass.CreateLink.apply(this,arguments)&&BX.bind(this.link,"click",BX.proxy(this.onClick,this)),this.boolResult},BX.AsTreeCondCtrlBaseSelect=function(parentContainer,state,params){return this.values=[],this.labels=[],this.multiple=!1,this.size=3,this.first_option="...",this.boolVisual=!1,this.visual=null,BX.AsTreeCondCtrlBaseSelect.superclass.constructor.apply(this,arguments)&&(BX.type.isNotEmptyString(params.multiple)&&(this.multiple="Y"===params.multiple),(BX.type.isString(params.size)||BX.type.isNumber(params.size))&&(params.size=parseInt(params.size,10),!isNaN(params.size)&&params.size>0&&(this.size=params.size)),BX.type.isNotEmptyString(params.first_option)&&(this.first_option=params.first_option),this.dontShowFirstOption=!!params.dontShowFirstOption),this.boolResult},BX.extend(BX.AsTreeCondCtrlBaseSelect,BX.AsTreeCondCtrlAtom),BX.AsTreeCondCtrlBaseSelect.prototype.Init=function(){return BX.AsTreeCondCtrlInput.superclass.Init.apply(this,arguments),this.boolResult},BX.AsTreeCondCtrlBaseSelect.prototype.setValueText=function(){var titles,i,j;for(BX.type.isString(this.valuesContainer[this.id])&&(this.valuesContainer[this.id]=this.valuesContainer[this.id].split(",")),titles=[],this.select.selectedIndex=-1,i=0;i<this.select.options.length;i++)BX.util.in_array(this.select.options[i].value,this.valuesContainer[this.id])&&(j=BX.util.array_search(this.select.options[i].value,this.values))>-1?(this.select.options[i].selected=!0,-1===this.select.selectedIndex&&(this.select.selectedIndex=i),titles[titles.length]=this.ViewFormat(this.values[j],this.labels[j])):this.select.options[i].selected=!1;0===titles.length&&(titles[0]=this.defaultText),BX.adjust(this.link,{html:BX.util.htmlspecialchars(titles.join(", "))}),titles=null},BX.AsTreeCondCtrlBaseSelect.prototype.SetValue=function(){var arText=[],arSelVal=[],i,j;if(this.multiple){for(i=0;i<this.select.options.length;i++)this.select.options[i].selected&&(arSelVal[arSelVal.length]=this.select.options[i].value,(j=BX.util.array_search(this.select.options[i].value,this.values))>-1&&(arText[arText.length]=this.ViewFormat(this.values[j],this.labels[j])));0===arText.length&&(arText[0]=this.defaultText),this.valuesContainer[this.id]=arSelVal}else 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),arText[0]=i>-1?this.ViewFormat(this.values[i],this.labels[i]):this.defaultText);BX.AsTreeCondCtrlBaseSelect.superclass.SetValue.apply(this,arguments)?BX.adjust(this.link,{html:BX.util.htmlspecialchars(arText.join(", "))}):BX.adjust(this.link,{html:this.defaultText})},BX.AsTreeCondCtrlBaseSelect.prototype.View=function(boolShow){BX.AsTreeCondCtrlBaseSelect.superclass.View.apply(this,arguments),boolShow?(BX.style(this.link,"display","none"),BX.style(this.select,"display",""),BX.focus(this.select)):(BX.style(this.select,"display","none"),BX.style(this.link,"display",""),this.select.blur())},BX.AsTreeCondCtrlBaseSelect.prototype.onChange=function(){this.SetValue(),this.multiple||this.View(!1),this.boolVisual&&this.visual()},BX.AsTreeCondCtrlBaseSelect.prototype.onBlur=function(){this.View(!1)},BX.AsTreeCondCtrlBaseSelect.prototype.onKeypress=function(e){if(e||(e=window.event),e.keyCode&&(13===e.keyCode||27===e.keyCode)&&(this.View(!1),13===e.keyCode))return BX.PreventDefault(e)},BX.AsTreeCondCtrlBaseSelect.prototype.onClick=function(){this.View(!0)},BX.AsTreeCondCtrlBaseSelect.prototype.Delete=function(){BX.AsTreeCondCtrlBaseSelect.superclass.Delete.apply(this,arguments),this.select&&(BX.unbindAll(this.select),this.select=BX.remove(this.select)),this.boolVisual&&(this.visual=null)},BX.AsTreeCondCtrlBaseSelect.prototype.CreateLink=function(){return BX.AsTreeCondCtrlBaseSelect.superclass.CreateLink.apply(this,arguments)&&BX.bind(this.link,"click",BX.proxy(this.onClick,this)),this.boolResult},BX.AsTreeCondCtrlBaseSelect.prototype.CreateSelect=function(){var props;props={id:this.parentContainer.id+"_"+this.id,name:this.name,className:"",selectedIndex:-1},this.multiple&&(props.name=this.name+"[]",props.multiple=!0,props.size=this.size),this.select=this.parentContainer.appendChild(BX.create("select",{props:props,style:{display:"none"},events:{change:BX.proxy(this.onChange,this),blur:BX.proxy(this.onBlur,this),keypress:BX.proxy(this.onKeypress,this)}})),BX.type.isElementNode(this.select)&&(this.multiple||this.dontShowFirstOption||this.select.appendChild(BX.create("option",{props:{value:""},html:this.first_option}))),props=null},BX.AsTreeCondCtrlSelect=function(parentContainer,state,arParams){var i;if(BX.AsTreeCondCtrlSelect.superclass.constructor.apply(this,arguments)){if(!BX.type.isPlainObject(arParams.values))return this.boolResult;for(i in arParams.values)arParams.values.hasOwnProperty(i)&&(this.values[this.values.length]=i,this.labels[this.labels.length]=arParams.values[i]);if(0===this.values.length)return this.boolResult;this.defaultValue.length>0&&(i=BX.util.array_search(this.defaultValue,this.values),this.defaultText=i>-1?this.labels[i]:""),BX.type.isPlainObject(arParams.events)&&BX.type.isFunction(arParams.events.visual)&&(this.boolVisual=!0,this.visual=arParams.events.visual),this.Init()}return this.boolResult},BX.extend(BX.AsTreeCondCtrlSelect,BX.AsTreeCondCtrlBaseSelect),BX.AsTreeCondCtrlSelect.prototype.Init=function(){var i;if(this.boolResult&&BX.AsTreeCondCtrlSelect.superclass.Init.apply(this,arguments)){if(this.CreateSelect(),BX.type.isElementNode(this.select)){for(i in this.values)this.values.hasOwnProperty(i)&&this.select.appendChild(BX.create("option",{props:{value:this.values[i]},html:BX.util.htmlspecialchars(this.ViewFormat(this.values[i],this.labels[i]))}));this.InitValue()}this.boolResult=!!this.select}return this.boolResult},BX.AsTreeCondCtrlSelect.prototype.InitValue=function(){BX.AsTreeCondCtrlSelect.superclass.InitValue.apply(this,arguments)?this.setValueText():this.select.selectedIndex=-1},BX.AsTreeCondCtrlSelect.prototype.CreateLink=function(){return BX.AsTreeCondCtrlSelect.superclass.CreateLink.apply(this,arguments)&&BX.bind(this.link,"click",BX.proxy(this.onClick,this)),this.boolResult},BX.AsTreeCondCtrlLazySelect=function(parentContainer,state,params){var i;if(this.loaded=!1,this.loadProgress=!1,this.loadUrl="",this.loadUrlParams={},BX.AsTreeCondCtrlLazySelect.superclass.constructor.apply(this,arguments)){if(BX.type.isNotEmptyString(params.load_url)&&(this.loadUrl=params.load_url),BX.type.isPlainObject(params.load_params))for(i in params.load_params)params.load_params.hasOwnProperty(i)&&(this.loadUrlParams[i]=params.load_params[i]);this.Init()}return this.boolResult},BX.extend(BX.AsTreeCondCtrlLazySelect,BX.AsTreeCondCtrlBaseSelect),BX.AsTreeCondCtrlLazySelect.prototype.Init=function(){return this.boolResult&&BX.AsTreeCondCtrlLazySelect.superclass.Init.apply(this,arguments)&&(this.CreateSelect(),this.InitValue()),this.boolResult},BX.AsTreeCondCtrlLazySelect.prototype.InitValue=function(){BX.AsTreeCondCtrlLazySelect.superclass.InitValue.apply(this,arguments)?this.loaded?this.setValueText():this.ajaxLoad("InitValue"):this.select.selectedIndex=-1},BX.AsTreeCondCtrlLazySelect.prototype.ajaxLoad=function(source){var ajaxParams={},i,successFunc;if(!this.loaded&&!this.loadProgress){for(i in this.loadUrlParams)this.loadUrlParams.hasOwnProperty(i)&&(ajaxParams[i]=this.loadUrlParams[i]);switch(ajaxParams.sessid=BX.bitrix_sessid(),ajaxParams.lang=BX.message("LANGUAGE_ID"),source){default:case"InitValue":successFunc=BX.proxy(this.ajaxLoadResultFromInit,this);break;case"onClick":successFunc=BX.proxy(this.ajaxLoadResultFromClick,this)}this.loadProgress=!0,BX.showWait(this.parentContainer),BX.ajax({method:"POST",dataType:"json",url:this.loadUrl,data:ajaxParams,onsuccess:successFunc}),successFunc=null,ajaxParams=null}},BX.AsTreeCondCtrlLazySelect.prototype.ajaxLoadResult=function(result){var i;if(this.loadProgress=!1,BX.closeWait(this.parentContainer),BX.type.isArray(result)){for(i=0;i<result.length;i++)this.values[this.values.length]=result[i].value,this.labels[this.labels.length]=result[i].label,this.select.appendChild(BX.create("option",{props:{value:result[i].value},html:BX.util.htmlspecialchars(this.ViewFormat(result[i].value,result[i].label))}));this.loaded=!0}},BX.AsTreeCondCtrlLazySelect.prototype.ajaxLoadResultFromInit=function(result){BX.type.isArray(result)&&(this.ajaxLoadResult(result),this.loaded&&this.setValueText())},BX.AsTreeCondCtrlLazySelect.prototype.ajaxLoadResultFromClick=function(result){BX.type.isArray(result)&&(this.ajaxLoadResult(result),this.loaded&&this.onClick())},BX.AsTreeCondCtrlLazySelect.prototype.onClick=function(){this.loaded?this.View(!0):this.ajaxLoad("onClick")},BX.AsTreeCondCtrlPopup=function(parentContainer,state,arParams){var i;if(BX.AsTreeCondCtrlPopup.superclass.constructor.apply(this,arguments)){if(!arParams.popup_url)return this.boolResult;if(this.popup_url=arParams.popup_url,this.popup_params={},arParams.popup_params)for(i in arParams.popup_params)arParams.popup_params.hasOwnProperty(i)&&(this.popup_params[i]=arParams.popup_params[i]);this.popup_param_id=null,BX.type.isNotEmptyString(arParams.param_id)&&(this.popup_param_id=arParams.param_id),this.label="",state.labels&&state.labels[this.id]&&(this.label=state.labels[this.id]),0===this.label.length&&(this.label=this.valuesContainer[this.id].length>0?this.valuesContainer[this.id]:this.defaultText),this.Init()}return this.boolResult},BX.extend(BX.AsTreeCondCtrlPopup,BX.AsTreeCondCtrlAtom),BX.AsTreeCondCtrlPopup.prototype.Init=function(){return this.boolResult&&BX.AsTreeCondCtrlPopup.superclass.Init.apply(this,arguments)&&(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),this.boolResult},BX.AsTreeCondCtrlPopup.prototype.CreateLink=function(){return 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),this.boolResult},BX.AsTreeCondCtrlPopup.prototype.PopupShow=function(){var url=this.popup_url,data=this.prepareData(this.popup_params),wnd;data.length>0&&(url+=(-1!==url.indexOf("?")?"&":"?")+data),window.open(url,"","scrollbars=yes,resizable=yes,width=900,height=600,top="+parseInt((screen.height-500)/2-14,10)+",left="+parseInt((screen.width-600)/2-5,10)).onbeforeunload=function(){BX.onCustomEvent("onTreeCondPopupClose")}},BX.AsTreeCondCtrlPopup.prototype.onChange=function(){this.valuesContainer[this.id]=this.input.value},BX.AsTreeCondCtrlPopup.prototype.Delete=function(){BX.AsTreeCondCtrlPopup.superclass.Delete.apply(this,arguments),this.input&&(BX.unbindAll(this.input),this.input=BX.remove(this.input))},BX.AsTreeUserCondCtrlPopup=function(parentContainer,state,arParams){var i;if(BX.AsTreeUserCondCtrlPopup.superclass.constructor.apply(this,arguments)){if(!arParams.popup_url)return this.boolResult;if(this.user_load_url=arParams.user_load_url,this.popup_url=arParams.popup_url,arParams.popup_params)for(i in arParams.popup_params)arParams.popup_params.hasOwnProperty(i)&&(this.popup_params[i]=arParams.popup_params[i]);this.popup_param_id=null,BX.type.isNotEmptyString(arParams.param_id)&&(this.popup_param_id=arParams.param_id),this.label="",state.labels&&state.labels[this.id]&&(this.label=state.labels[this.id]),0===this.label.length&&(this.label=this.valuesContainer[this.id].length>0?this.valuesContainer[this.id]:this.defaultText)}return this.boolResult},BX.extend(BX.AsTreeUserCondCtrlPopup,BX.AsTreeCondCtrlPopup),BX.AsTreeUserCondCtrlPopup.prototype.Init=function(){var i;if(this.inputs=[],""===this.valuesContainer[this.id]&&(this.valuesContainer[this.id]=[],this.label=[]),BX.type.isArray(this.valuesContainer[this.id])||(this.valuesContainer[this.id]=[this.valuesContainer[this.id]],this.label=[this.label]),this.boolResult&&BX.AsTreeUserCondCtrlPopup.superclass.Init.apply(this,arguments)){if(this.input&&(BX.unbindAll(this.input),this.input=BX.remove(this.input)),this.popup_param_id&&(this.popup_params[this.popup_param_id]=this.parentContainer.id+"_"+this.id),this.IsValue())for(i in this.valuesContainer[this.id])this.valuesContainer[this.id].hasOwnProperty(i)&&this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",this.valuesContainer[this.id][i]);else this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]","");this.AppendFakeInputNode(this.parentContainer.id+"_"+this.id,this.name),this.boolResult=!!this.inputs}return this.boolResult},BX.AsTreeUserCondCtrlPopup.prototype.CreateLink=function(){var i;if(this.popup_params.FN="sale_discount_form",this.popup_params.FC="fake_"+this.name,this.boolResult){for(i in 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]})),this.valuesContainer[this.id])this.valuesContainer[this.id].hasOwnProperty(i)&&this.AppendItemNode(this.valuesContainer[this.id][i],this.label[i]);this.boolResult=!!this.link}return this.boolResult},BX.AsTreeUserCondCtrlPopup.prototype.AppendItemNode=function(value,label){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(value,label))}),BX.create("SPAN",{props:{className:"condition-item-del"},attrs:{"bx-data-value":value},events:{click:BX.proxy(this.DeleteItem,this)}})]}),this.defaultLabel)},BX.AsTreeUserCondCtrlPopup.prototype.AppendInputNode=function(id,name,value){this.inputs.push(this.parentContainer.appendChild(BX.create("INPUT",{props:{type:"hidden",id:id,name:name,value:value},style:{display:"none"},events:{change:BX.proxy(this.onChange,this)}})))},BX.AsTreeUserCondCtrlPopup.prototype.AppendFakeInputNode=function(id,name){this.inputs.push(this.parentContainer.appendChild(BX.create("INPUT",{props:{type:"hidden",id:"fake_"+id,name:"fake_"+name},style:{display:"none"},events:{change:BX.proxy(this.onChangeFake,this)}})))},BX.AsTreeUserCondCtrlPopup.prototype.onChangeFake=function(params){var userId=params.target.value;BX.ajax({method:"POST",dataType:"json",url:this.user_load_url,data:{sessid:BX.bitrix_sessid(),AJAX_ACTION:"getUserName",USER_ID:userId},onsuccess:BX.delegate((function(data){var name=data.name;this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",userId),this.AppendItemNode(userId,name),this.valuesContainer[this.id].push(userId)}),this)})},BX.AsTreeUserCondCtrlPopup.prototype.onSave=function(params){BX.type.isPlainObject(params)&&(this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",params.id),this.AppendItemNode(params.id,params.name),this.valuesContainer[this.id].push(params.id))},BX.AsTreeUserCondCtrlPopup.prototype.DeleteItem=function(e){var srcElement=e.target||e.srcElement,itemContainer;srcElement?BX.findParent(srcElement,{className:"condition-item",tagName:"span"},3)?(BX.remove(BX.findParent(srcElement,{className:"condition-item",tagName:"span"},3)),BX.remove(BX.findChild(this.parentContainer,{tagName:"input",attribute:{name:this.name+"[]",value:srcElement.getAttribute("bx-data-value")}},3)),BX.PreventDefault(e)):BX.PreventDefault(e):BX.PreventDefault(e)},BX.AsTreeUserCondCtrlPopup.prototype.Delete=function(){if(BX.AsTreeUserCondCtrlPopup.superclass.Delete.apply(this,arguments),this.input&&(BX.unbindAll(this.input),this.input=BX.remove(this.input)),this.inputs){for(var i in this.inputs)this.inputs.hasOwnProperty(i)&&(BX.unbindAll(this.inputs[i]),BX.remove(this.inputs[i]),delete this.inputs[i]);this.inputs=[]}this.dialog&&(this.dialog=null)},BX.AsTreeCondCtrlDialog=function(parentContainer,state,arParams){var data;return BX.AsTreeCondCtrlDialog.superclass.constructor.apply(this,arguments)&&(this.popup_params.event="onTreeCondDialogSave",(data=this.prepareData(this.popup_params)).length>0&&(this.popup_url+=(-1!==this.popup_url.indexOf("?")?"&":"?")+data),this.dialog=null),this.boolResult},BX.extend(BX.AsTreeCondCtrlDialog,BX.AsTreeCondCtrlPopup),BX.AsTreeCondCtrlDialog.prototype.CreateLink=function(){return 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),this.boolResult},BX.AsTreeCondCtrlDialog.prototype.onChange=function(){this.valuesContainer[this.id]=this.input.value},BX.AsTreeCondCtrlDialog.prototype.DialogShow=function(){null!==this.dialog&&(this.dialog=null),this.dialog=new BX.CAdminDialog({content_url:this.popup_url,height:Math.max(500,window.innerHeight-400),width:Math.max(800,window.innerWidth-400),draggable:!0,resizable:!0,min_height:500,min_width:800}),this.dialog&&(BX.addCustomEvent("onTreeCondDialogSave",BX.proxy(this.onSave,this)),this.dialog.Show())},BX.AsTreeCondCtrlDialog.prototype.onSave=function(params){BX.removeCustomEvent("onTreeCondDialogSave",BX.proxy(this.onSave,this)),BX.type.isPlainObject(params)&&(this.input.value=params.id,this.link.innerHTML=BX.util.htmlspecialchars(this.ViewFormat(params.id,params.name)),this.onChange()),this.dialog.Close(),this.dialog=null},BX.AsTreeCondCtrlDialog.prototype.Delete=function(){BX.AsTreeCondCtrlDialog.superclass.Delete.apply(this,arguments),this.input&&(BX.unbindAll(this.input),this.input=BX.remove(this.input)),this.dialog&&(this.dialog=null)},BX.AsTreeMultiCondCtrlDialog=function(parentContainer,state,arParams){var data;return this.defaultLabel=null,BX.AsTreeMultiCondCtrlDialog.superclass.constructor.apply(this,arguments)&&(this.popup_params.event="onTreeCondDialogSave",(data=this.prepareData(this.popup_params)).length>0&&(this.popup_url+=(-1!==this.popup_url.indexOf("?")?"&":"?")+data),this.dialog=null,BX.addClass(parentContainer,"condition-multi")),this.boolResult},BX.extend(BX.AsTreeMultiCondCtrlDialog,BX.AsTreeCondCtrlPopup),BX.AsTreeMultiCondCtrlDialog.prototype.AppendItemNode=function(value,label){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(value,label))}),BX.create("SPAN",{props:{className:"condition-item-del"},attrs:{"bx-data-value":value},events:{click:BX.proxy(this.DeleteItem,this)}})]}),this.defaultLabel)},BX.AsTreeMultiCondCtrlDialog.prototype.AppendInputNode=function(id,name,value){this.inputs.push(this.parentContainer.appendChild(BX.create("INPUT",{props:{type:"hidden",id:id,name:name,value:value},style:{display:"none"},events:{change:BX.proxy(this.onChange,this)}})))},BX.AsTreeMultiCondCtrlDialog.prototype.Init=function(){var i;if(this.inputs=[],""===this.valuesContainer[this.id]&&(this.valuesContainer[this.id]=[],this.label=[]),BX.type.isArray(this.valuesContainer[this.id])||(this.valuesContainer[this.id]=[this.valuesContainer[this.id]],this.label=[this.label]),this.boolResult&&BX.AsTreeMultiCondCtrlDialog.superclass.Init.apply(this,arguments)){if(this.input&&(BX.unbindAll(this.input),this.input=BX.remove(this.input)),this.popup_param_id&&(this.popup_params[this.popup_param_id]=this.parentContainer.id+"_"+this.id),this.IsValue())for(i in this.valuesContainer[this.id])this.valuesContainer[this.id].hasOwnProperty(i)&&this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",this.valuesContainer[this.id][i]);else this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]","");this.boolResult=!!this.inputs}return this.boolResult},BX.AsTreeMultiCondCtrlDialog.prototype.CreateLink=function(){var i;if(this.boolResult){for(i in 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]})),this.valuesContainer[this.id])this.valuesContainer[this.id].hasOwnProperty(i)&&this.AppendItemNode(this.valuesContainer[this.id][i],this.label[i]);this.boolResult=!!this.link}return this.boolResult},BX.AsTreeMultiCondCtrlDialog.prototype.onChange=function(){},BX.AsTreeMultiCondCtrlDialog.prototype.DialogShow=function(){null!==this.dialog&&(this.dialog=null),this.dialog=new BX.CAdminDialog({content_url:this.popup_url,height:Math.max(500,window.innerHeight-400),width:Math.max(800,window.innerWidth-400),draggable:!0,resizable:!0,min_height:500,min_width:800}),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.AsTreeMultiCondCtrlDialog.prototype.onSave=function(params){BX.type.isPlainObject(params)&&(this.AppendInputNode(this.parentContainer.id+"_"+this.id,this.name+"[]",params.id),this.AppendItemNode(params.id,params.name),this.valuesContainer[this.id].push(params.id))},BX.AsTreeMultiCondCtrlDialog.prototype.DeleteItem=function(e){var srcElement=e.target||e.srcElement,itemContainer;srcElement?BX.findParent(srcElement,{className:"condition-item",tagName:"span"},3)?(BX.remove(BX.findParent(srcElement,{className:"condition-item",tagName:"span"},3)),BX.remove(BX.findChild(this.parentContainer,{tagName:"input",attribute:{name:this.name+"[]",value:srcElement.getAttribute("bx-data-value")}},3)),BX.PreventDefault(e)):BX.PreventDefault(e):BX.PreventDefault(e)},BX.AsTreeMultiCondCtrlDialog.prototype.Delete=function(){if(BX.AsTreeMultiCondCtrlDialog.superclass.Delete.apply(this,arguments),this.input&&(BX.unbindAll(this.input),this.input=BX.remove(this.input)),this.inputs){for(var i in this.inputs)this.inputs.hasOwnProperty(i)&&(BX.unbindAll(this.inputs[i]),BX.remove(this.inputs[i]),delete this.inputs[i]);this.inputs=[]}this.dialog&&(this.dialog=null)},BX.AsTreeCondCtrlDateTime=function(parentContainer,state,arParams){return BX.AsTreeCondCtrlDateTime.superclass.constructor.apply(this,arguments)&&(this.format=arParams.format&&"date"===arParams.format?"date":"datetime",this.Init()),this.boolResult},BX.extend(BX.AsTreeCondCtrlDateTime,BX.AsTreeCondCtrlAtom),BX.AsTreeCondCtrlDateTime.prototype.Init=function(){this.boolResult&&BX.AsTreeCondCtrlDateTime.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.AsTreeCondCtrlDateTime.prototype.InitValue=function(){BX.AsTreeCondCtrlDateTime.superclass.InitValue.apply(this,arguments)?(BX.adjust(this.link,{html:BX.util.htmlspecialchars(this.valuesContainer[this.id])}),this.input.value=this.valuesContainer[this.id]):(BX.adjust(this.link,{html:this.defaultText}),this.input.value="")},BX.AsTreeCondCtrlDateTime.prototype.SetValue=function(){this.valuesContainer[this.id]=this.input.value,BX.AsTreeCondCtrlDateTime.superclass.SetValue.apply(this,arguments)?BX.adjust(this.link,{html:BX.util.htmlspecialchars(this.valuesContainer[this.id])}):BX.adjust(this.link,{html:this.defaultText})},BX.AsTreeCondCtrlDateTime.prototype.View=function(boolShow){BX.AsTreeCondCtrlDateTime.superclass.View.apply(this,arguments),boolShow?(BX.style(this.link,"display","none"),BX.style(this.calendar,"display","inline-block"),BX.focus(this.input)):(BX.style(this.calendar,"display","none"),BX.style(this.link,"display",""))},BX.AsTreeCondCtrlDateTime.prototype.Delete=function(){BX.AsTreeCondCtrlDateTime.superclass.Delete.apply(this,arguments),this.input&&(BX.unbindAll(this.input),this.input=BX.remove(this.input)),this.icon&&(BX.unbindAll(this.icon),this.icon=BX.remove(this.icon)),this.calendarText&&(this.calendarText=BX.remove(this.calendarText)),this.calendar&&(BX.unbindAll(this.calendar),this.calendar=BX.remove(this.calendar))},BX.AsTreeCondCtrlDateTime.prototype.CreateLink=function(){return BX.AsTreeCondCtrlDateTime.superclass.CreateLink.apply(this,arguments)&&BX.bind(this.link,"click",BX.proxy(this.onClick,this)),this.boolResult},BX.AsTreeCondCtrlDateTime.prototype.ShowCalendarControl=function(){this.calendarText&&BX.calendar({node:this.calendarText,field:this.input,form:"",bTime:"datetime"===this.format,bHideTime:!1})},BX.AsTreeConditions=function(arParams,obTree,obControls){var i;if(BX.onCustomEvent("onTreeConditionsInit",[arParams,obTree,obControls]),this.boolResult=!1,!arParams||"object"!=typeof arParams||!arParams.parentContainer)return this.boolResult;if(this.parentContainer=arParams.parentContainer,!arParams.form&&!arParams.formName)return this.boolResult;if(this.arStartParams=arParams,this.form=arParams.form?arParams.form:null,this.formName=arParams.formName?arParams.formName:null,this.mess=null,BX.type.isPlainObject(arParams.mess)&&(this.mess=arParams.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")},BX.type.isPlainObject(arParams.messTree))for(i in arParams.messTree)arParams.messTree.hasOwnProperty(i)&&(this.messTree[i]=arParams.messTree[i]);if(this.sepID=arParams.sepID?arParams.sepID:"__",this.sepName=arParams.sepName?arParams.sepName:this.sepID,this.prefix=arParams.prefix?arParams.prefix:"rule",this.AtomTypes={prefix:BX.AsTreeCondCtrlAtom,input:BX.AsTreeCondCtrlInput,select:BX.AsTreeCondCtrlSelect,lazySelect:BX.AsTreeCondCtrlLazySelect,popup:BX.AsTreeCondCtrlPopup,userPopup:BX.AsTreeUserCondCtrlPopup,datetime:BX.AsTreeCondCtrlDateTime,dialog:BX.AsTreeCondCtrlDialog,multiDialog:BX.AsTreeMultiCondCtrlDialog},arParams.atomtypes&&"object"==typeof arParams.atomtypes)for(i in arParams.atomtypes)arParams.atomtypes.hasOwnProperty(i)&&!this.AtomTypes[i]&&(this.AtomTypes[i]=arParams.atomtypes[i]);return obTree&&"object"==typeof obTree?(this.tree=obTree,obControls&&BX.type.isArray(obControls)?(this.controls=obControls,this.boolResult=!0,BX.ready(BX.delegate(this.RenderTree,this)),this.boolResult):this.boolResult):this.boolResult},BX.AsTreeConditions.prototype.Delete=function(){this.tree&&this.DeleteLevel(this.tree)},BX.AsTreeConditions.prototype.ControlSearch=function(controlId){var curControl=!1,i;if(this.boolResult&&this.controls)for(i=0;i<this.controls.length;i++)if(this.controls[i].controlgroup){if(!1!==(curControl=this.ControlInGrpSearch(this.controls[i].children,controlId)))break}else if(controlId===this.controls[i].controlId){curControl=this.controls[i];break}return curControl},BX.AsTreeConditions.prototype.ControlInGrpSearch=function(controls,controlId){var curControl=!1,i;if(this.boolResult&&controls)for(i=0;i<controls.length;i++)if(controlId===controls[i].controlId){curControl=controls[i];break}return curControl},BX.AsTreeConditions.prototype.RenderTree=function(){return this.boolResult&&(this.form=this.form?BX(this.form):document.forms[this.formName],this.form?(this.formName=this.form.name,this.parentContainer=BX(this.parentContainer),this.parentContainer?(BX.adjust(this.parentContainer,{style:{position:"relative",zIndex:1}}),this.RenderLevel(this.parentContainer,null,this.tree)):this.boolResult=!1):this.boolResult=!1),this.boolResult},BX.AsTreeConditions.prototype.RenderLevel=function(parentContainer,obParent,obTreeLevel,obParams){var CurControl,strContClassName,wrapper=null,logic=null,div=null,zIndex,i,j,k,elem,item,params,intCurrentIndex,obLogicParams;if(this.boolResult){if(!parentContainer)return this.boolResult=!1,this.boolResult;if("object"!=typeof obTreeLevel)return this.boolResult=!1,this.boolResult;if(null===obTreeLevel.id||void 0===obTreeLevel.id)return this.boolResult=!1,this.boolResult;if(null===obTreeLevel.controlId||void 0===obTreeLevel.controlId)return this.boolResult=!1,this.boolResult;if(!(CurControl=this.ControlSearch(obTreeLevel.controlId)))return this.boolResult=!1,this.boolResult;if(strContClassName=CurControl.group?null!==obParent?"condition-container":"condition-border":"condition-simple-control",zIndex=parseInt(BX.style(parentContainer,"z-index"),10),isNaN(zIndex)&&(zIndex=1),!(div=(wrapper=BX.create("DIV",{props:{id:parentContainer.id+this.sepID+obTreeLevel.id+"_wrap",className:"condition-wrapper"},style:{zIndex:zIndex+100}})).appendChild(BX.create("DIV",{props:{id:parentContainer.id+this.sepID+obTreeLevel.id,className:strContClassName},style:{zIndex:zIndex+110}}))))return this.boolResult=!1,this.boolResult;if(0===parentContainer.childNodes.length?parentContainer.appendChild(wrapper):parentContainer.insertBefore(wrapper,parentContainer.childNodes[parentContainer.childNodes.length-1]),div.appendChild(BX.create("INPUT",{props:{type:"hidden",id:div.id+"_controlId",name:(this.prefix+"["+parentContainer.id+this.sepID+obTreeLevel.id+"][controlId]").replace(this.parentContainer.id+this.sepID,""),className:"",value:obTreeLevel.controlId}})),obTreeLevel.wrapper=wrapper,obTreeLevel.logic=null,obTreeLevel.container=div,obTreeLevel.obj=[],obTreeLevel.addBtn=null,obTreeLevel.deleteBtn=null,obTreeLevel.visual=null,null!==obParent&&(null!==obTreeLevel.showDeleteButton&&void 0!==obTreeLevel.showDeleteButton&&!0!==obTreeLevel.showDeleteButton||this.RenderDeleteBtn(obTreeLevel,obParent,CurControl)),obTreeLevel.err_cond&&"Y"===obTreeLevel.err_cond&&div.appendChild(BX.create("SPAN",{props:{className:"condition-alert",title:obTreeLevel.err_cond_mess?obTreeLevel.err_cond_mess:obTreeLevel.fatal_err_cond?this.messTree.CONDITION_FATAL_ERROR:this.messTree.CONDITION_ERROR}})),!obTreeLevel.fatal_err_cond){for(CurControl.group&&CurControl.visual&&"object"==typeof CurControl.visual&&(obTreeLevel.visual=CurControl.visual,obTreeLevel.visual.values&&BX.type.isArray(obTreeLevel.visual.values)&&obTreeLevel.visual.logic&&BX.type.isArray(obTreeLevel.visual.logic)&&obTreeLevel.visual.values.length===obTreeLevel.visual.logic.length||(obTreeLevel.visual=null)),i=0;i<CurControl.control.length;i++)if(elem=null,0<i&&div.appendChild(BX.create("SPAN",{props:{className:"condition-space"},html:"&nbsp;"})),"object"==typeof(item=CurControl.control[i])){for(k in params={},item)item.hasOwnProperty(k)&&(params[k]="name"===k?(this.prefix+"["+parentContainer.id+this.sepID+obTreeLevel.id+"]["+item[k]+"]").replace(this.parentContainer.id+this.sepID,""):item[k]);obTreeLevel.visual&&BX.util.in_array(item.id,obTreeLevel.visual.controls)&&(params.events||(params.events={}),params.events.visual=BX.delegate((function(){this.ChangeVisual(obTreeLevel)}),this)),this.AtomTypes[item.type]&&("prefix"===item.type?elem=new this.AtomTypes[item.type](div,obTreeLevel,params):(elem=new this.AtomTypes[item.type](div,obTreeLevel,params),obTreeLevel.obj[obTreeLevel.obj.length]=elem))}else elem=new BX.AsTreeCondCtrlAtom(div,obTreeLevel,item);if(CurControl.group&&(div.appendChild(BX.create("DIV",{props:{className:"condition-group-sep"}})),CurControl.containsOneAction?this.RenderCreateOneActionBtn(obTreeLevel,CurControl):this.RenderCreateBtn(obTreeLevel,CurControl),obTreeLevel.children&&obTreeLevel.children.length&&obTreeLevel.children.length>0))if(obTreeLevel.visual&&"object"==typeof obTreeLevel.visual)if(-1<(intCurrentIndex=this.SearchVisual(obTreeLevel)))for((obLogicParams=obTreeLevel.visual.logic[intCurrentIndex]).visual=BX.delegate((function(){this.NextVisual(obTreeLevel)}),this),j=0;j<obTreeLevel.children.length;j++)this.RenderLevel(div,obTreeLevel,obTreeLevel.children[j]),j<obTreeLevel.children.length-1&&this.CreateLogic(obTreeLevel.children[j],obTreeLevel,obLogicParams);else for(j=0;j<obTreeLevel.children.length;j++)this.RenderLevel(div,obTreeLevel,obTreeLevel.children[j]);else for(j=0;j<obTreeLevel.children.length;j++)this.RenderLevel(div,obTreeLevel,obTreeLevel.children[j])}}return this.boolResult},BX.AsTreeConditions.prototype.CreateLevel=function(obTreeLevel,controlId,num){var indexPrev,intCurrentIndex,obLogicParams;obTreeLevel&&obTreeLevel.children&&(null==num&&(num=obTreeLevel.children.length),obTreeLevel.children[obTreeLevel.children.length]={id:num,controlId:controlId,values:{},children:[]},this.RenderLevel(obTreeLevel.container,obTreeLevel,obTreeLevel.children[obTreeLevel.children.length-1])?(-1<(indexPrev=this.SearchForCreateLogic(obTreeLevel))&&-1<(intCurrentIndex=this.SearchVisual(obTreeLevel))&&((obLogicParams=obTreeLevel.visual.logic[intCurrentIndex]).visual=BX.delegate((function(){this.NextVisual(obTreeLevel)}),this),this.CreateLogic(obTreeLevel.children[indexPrev],obTreeLevel,obLogicParams)),BX.onCustomEvent("onAdminTabsChange")):obTreeLevel.children.pop())},BX.AsTreeConditions.prototype.SearchForDeleteLevel=function(obTreeLevel,obParent){var arRes={indexDel:-1,indexPrev:-1},j,boolNeedDelVisual;if(obParent&&obParent.children){for(j=0;j<obParent.children.length;j++)if(obParent.children[j]&&obParent.children[j]===obTreeLevel){arRes.indexDel=j;break}if(-1<arRes.indexDel&&obParent.visual&&"object"==typeof obParent.visual){for(boolNeedDelVisual=!0,j=arRes.indexDel+1;j<obParent.children.length;j++)if(obParent.children[j]){boolNeedDelVisual=!1;break}if(boolNeedDelVisual)for(j=arRes.indexDel-1;j>-1;j--)if(obParent.children[j]){arRes.indexPrev=j;break}}}return arRes},BX.AsTreeConditions.prototype.SearchForCreateLogic=function(obTreeLevel,indexCurrent){var indexPrev=-1,j;if(obTreeLevel&&obTreeLevel.children&&obTreeLevel.visual&&"object"==typeof obTreeLevel.visual)for(null==indexCurrent&&(indexCurrent=obTreeLevel.children.length-1),j=indexCurrent-1;j>-1;j--)if(obTreeLevel.children[j]){indexPrev=j;break}return indexPrev},BX.AsTreeConditions.prototype.DeleteLevel=function(obTreeLevel,obParent){var j,arDel;if(obTreeLevel){if(obTreeLevel.children){if(obTreeLevel.children.length>0)for(j=0;j<obTreeLevel.children.length;j++)this.DeleteLevel(obTreeLevel.children[j]);obTreeLevel.children.length=0}if(obTreeLevel.addBtn&&(obTreeLevel.addBtn.link&&(BX.unbindAll(obTreeLevel.addBtn.link),obTreeLevel.addBtn.link=BX.remove(obTreeLevel.addBtn.link)),obTreeLevel.addBtn.select&&(BX.unbindAll(obTreeLevel.addBtn.select),obTreeLevel.addBtn.link=BX.remove(obTreeLevel.addBtn.select)),obTreeLevel.addBtn=BX.remove(obTreeLevel.addBtn)),obTreeLevel.obj&&obTreeLevel.obj.length>0){for(j=0;j<obTreeLevel.obj.length;j++)obTreeLevel.obj[j].Delete();obTreeLevel.obj.length=0}obTreeLevel.deleteBtn&&(BX.unbindAll(obTreeLevel.deleteBtn),obTreeLevel.deleteBtn=BX.remove(obTreeLevel.deleteBtn)),BX.unbindAll(obTreeLevel.container),obTreeLevel.container=BX.remove(obTreeLevel.container),obTreeLevel.logic&&(BX.unbindAll(obTreeLevel.logic),obTreeLevel.logic=BX.remove(obTreeLevel.logic)),BX.unbindAll(obTreeLevel.wrapper),obTreeLevel.wrapper=BX.remove(obTreeLevel.wrapper),-1<(arDel=this.SearchForDeleteLevel(obTreeLevel,obParent)).indexDel&&(obParent.children[arDel.indexDel]=null,obTreeLevel=null),-1<arDel.indexPrev&&this.DeleteLogic(obParent.children[arDel.indexPrev]),BX.onCustomEvent("onAdminTabsChange"),BX.onCustomEvent("onAdminTabsDeleteLevel",[obTreeLevel,obParent])}},BX.AsTreeConditions.prototype.RenderCreateBtn=function(obTreeLevel,CurControl){var divAdd,addBtn,addSelect,i,j,grp,found;if(this.boolResult)if(obTreeLevel.container){if(CurControl.group){if(!(divAdd=obTreeLevel.container.appendChild(BX.create("DIV",{props:{id:obTreeLevel.container.id+"_add",className:"condition-add"}}))))return this.boolResult=!1,this.boolResult;if(obTreeLevel.addBtn=divAdd,addBtn=divAdd.appendChild(BX.create("A",{props:{id:divAdd.id+"_link",className:""},style:{display:""},html:CurControl.mess&&CurControl.mess.ADD_CONTROL?CurControl.mess.ADD_CONTROL:this.messTree.ADD_CONTROL})),addSelect=divAdd.appendChild(BX.create("SELECT",{props:{id:divAdd.id+"_select",className:""},style:{display:"none"}})))for(addSelect.appendChild(BX.create("OPTION",{props:{value:""},html:CurControl.mess&&CurControl.mess.SELECT_CONTROL?CurControl.mess.SELECT_CONTROL:this.messTree.SELECT_CONTROL})),i=0;i<this.controls.length;i++)if(BX.util.in_array(CurControl.controlId,this.controls[i].showIn))if(this.controls[i].controlgroup){if(found=!1,(grp=BX.create("OPTGROUP",{props:{label:this.controls[i].label}}))&&this.controls[i].children&&this.controls[i].children.length&&this.controls[i].children.length>0){for(j=0;j<this.controls[i].children.length;j++)BX.util.in_array(CurControl.controlId,this.controls[i].children[j].showIn)&&(found=!0,grp.appendChild(BX.create("OPTION",{props:{value:this.controls[i].children[j].controlId},html:BX.util.htmlspecialchars(this.controls[i].children[j].label)})));found&&addSelect.appendChild(grp)}}else addSelect.appendChild(BX.create("OPTION",{props:{value:this.controls[i].controlId},html:BX.util.htmlspecialchars(this.controls[i].label)}));addBtn&&addSelect?(divAdd.link=addBtn,divAdd.select=addSelect,BX.bind(addBtn,"click",BX.delegate((function(){BX.style(divAdd.select,"display",""),BX.style(divAdd.link,"display","none"),BX.focus(divAdd.select)}),divAdd)),BX.bind(addSelect,"change",BX.delegate((function(){0<divAdd.select.selectedIndex&&this.CreateLevel(obTreeLevel,divAdd.select.options[divAdd.select.selectedIndex].value),divAdd.select.selectedIndex=0,BX.style(divAdd.select,"display","none"),BX.style(divAdd.link,"display","")}),this)),BX.bind(addSelect,"blur",BX.delegate((function(){divAdd.select.selectedIndex=0,BX.style(divAdd.select,"display","none"),BX.style(divAdd.link,"display","")}),divAdd)),BX.bind(addSelect,"keypress",BX.delegate((function(e){if(e||(e=window.event),e.keyCode&&(13===e.keyCode||27===e.keyCode)&&(13===e.keyCode?(0<divAdd.select.selectedIndex&&this.CreateLevel(obTreeLevel),divAdd.select.selectedIndex=0):divAdd.select.selectedIndex=0,BX.style(divAdd.select,"display","none"),BX.style(divAdd.link,"display",""),13===e.keyCode))return BX.PreventDefault(e)}),this))):this.boolResult=!1}}else this.boolResult=!1;return this.boolResult},BX.AsTreeConditions.prototype.RenderCreateOneActionBtn=function(obTreeLevel,CurControl){if(this.RenderCreateBtn(obTreeLevel,CurControl)){BX.bind(obTreeLevel.addBtn.select,"change",(function(){BX.hide(obTreeLevel.addBtn)})),BX.adjust(obTreeLevel.addBtn,{attrs:{"bx-data-create-one-action-btn":!0}});var addBtnId=BX.clone(obTreeLevel.addBtn.id,!0);BX.addCustomEvent("onAdminTabsDeleteLevel",(function(obTreeLevel,obParent){obParent&&obParent.addBtn&&obParent.addBtn.getAttribute("bx-data-create-one-action-btn")&&obParent.addBtn.id===addBtnId&&BX.show(obParent.addBtn,"block")}));var isEmptyObject=function(obj){if(null==obj)return!0;if(obj.length&&obj.length>0)return!1;if(0===obj.length)return!0;for(var key in obj)if(hasOwnProperty.call(obj,key))return!1;return!0};obTreeLevel.children&&!isEmptyObject(obTreeLevel.children)&&BX.hide(obTreeLevel.addBtn)}return this.boolResult},BX.AsTreeConditions.prototype.RenderDeleteBtn=function(obTreeLevel,obParent,currentControl){var delBtn;return this.boolResult&&(obTreeLevel.container&&(delBtn=obTreeLevel.container.appendChild(BX.create("DIV",{props:{id:obTreeLevel.id+"_del",className:"condition-delete",title:BX.type.isPlainObject(currentControl.mess)&&BX.type.isNotEmptyString(currentControl.mess.DELETE_CONTROL)?currentControl.mess.DELETE_CONTROL:this.messTree.DELETE_CONTROL}})))?(obTreeLevel.delBtn=delBtn,BX.bind(delBtn,"click",BX.delegate((function(){this.DeleteLevel(obTreeLevel,obParent)}),this)),BX.bind(obTreeLevel.container,"mouseover",BX.delegate((function(e){return BX.style(delBtn,"display","block"),BX.eventCancelBubble(e)}),this)),BX.bind(obTreeLevel.container,"mouseout",BX.delegate((function(e){return BX.style(delBtn,"display","none"),BX.eventCancelBubble(e)}),this))):this.boolResult=!1),this.boolResult},BX.AsTreeConditions.prototype.CreateLogic=function(obTreeLevel,obParent,obParams){var logic,strClass;return this.boolResult&&(obTreeLevel.logic&&"object"==typeof obTreeLevel.logic?this.boolResult=this.UpdateLogic(obTreeLevel,obParams):(strClass="condition-logic",obParams.style&&(strClass=strClass.concat(" ",obParams.style)),(logic=BX.create("DIV",{props:{className:strClass},style:{zIndex:parseInt(BX.style(obTreeLevel.wrapper,"z-index"),10)+1},html:obParams.message}))?(obTreeLevel.wrapper.insertBefore(logic,obTreeLevel.wrapper.childNodes[0]),obTreeLevel.logic=logic,BX.bind(obTreeLevel.logic,"click",obParams.visual)):this.boolResult=!1)),this.boolResult},BX.AsTreeConditions.prototype.DeleteLogic=function(obTreeLevel){return this.boolResult&&obTreeLevel.logic&&"object"==typeof obTreeLevel.logic&&(BX.unbindAll(obTreeLevel.logic),obTreeLevel.logic=BX.remove(obTreeLevel.logic)),this.boolResult},BX.AsTreeConditions.prototype.UpdateLogic=function(obTreeLevel,obParams){var strClass;return this.boolResult&&obTreeLevel.logic&&"object"==typeof obTreeLevel.logic&&(strClass="condition-logic",obParams.style&&(strClass=strClass.concat(" ",obParams.style)),BX.adjust(obTreeLevel.logic,{props:{className:strClass},html:obParams.message})),this.boolResult},BX.AsTreeConditions.prototype.SearchVisual=function(obTreeLevel){var intCurrentIndex=-1,arCurrent,strName,i,j,k,oneRow,boolEqual;if(this.boolResult&&obTreeLevel.visual&&"object"==typeof obTreeLevel.visual&&obTreeLevel.visual.controls){for(i in arCurrent={},obTreeLevel.visual.controls)obTreeLevel.visual.controls.hasOwnProperty(i)&&(arCurrent[strName=obTreeLevel.visual.controls[i]]=obTreeLevel.values[strName]);if(obTreeLevel.visual.values)for(j=0;j<obTreeLevel.visual.values.length;j++){for(k in oneRow=obTreeLevel.visual.values[j],boolEqual=!0,arCurrent)if(oneRow[k]!=arCurrent[k]){boolEqual=!1;break}if(boolEqual){intCurrentIndex=j;break}}}return intCurrentIndex},BX.AsTreeConditions.prototype.ChangeVisual=function(obTreeLevel){var intCurrentIndex,obParams,j;if(this.boolResult&&-1<(intCurrentIndex=this.SearchVisual(obTreeLevel)))for(obParams=obTreeLevel.visual.logic[intCurrentIndex],j=0;j<obTreeLevel.children.length;j++)obTreeLevel.children[j]&&this.UpdateLogic(obTreeLevel.children[j],obParams);return this.boolResult},BX.AsTreeConditions.prototype.NextVisual=function(obTreeLevel){var intCurrentIndex,arValues,i,j,obParams;if(this.boolResult){if(-1<(intCurrentIndex=this.SearchVisual(obTreeLevel))){for(j in++intCurrentIndex>=obTreeLevel.visual.logic.length&&(intCurrentIndex=0),arValues=obTreeLevel.visual.values[intCurrentIndex])arValues.hasOwnProperty(j)&&(obTreeLevel.values[j]=arValues[j]);for(i=0;i<obTreeLevel.obj.length;i++)obTreeLevel.obj[i].ReInitValue(obTreeLevel.visual.controls);for(obParams=obTreeLevel.visual.logic[intCurrentIndex],i=0;i<obTreeLevel.children.length;i++)obTreeLevel.children[i]&&this.UpdateLogic(obTreeLevel.children[i],obParams)}BX.onCustomEvent("onNextVisualChange",[obTreeLevel])}})}(window);
//# sourceMappingURL=core_tree.min.js.map