Your IP : 3.15.138.33
BX.namespace("BX.Bizproc");BX.Bizproc.UserSelector=function(t){"use strict";var e=function(e){this.id="bp-user-selector-"+t.util.getRandomString(7);this.bindTo=e.bindTo;this.selected={};if(e.selected){for(var i=0;i<e.selected.length;++i){this.selected[e.selected[i].id]="user"}}this.addCallback=e.addCallback;this.parentPopup=e.parentPopup;this.bind()};e.canUse=function(){return!!t.SocNetLogDestination};e.loadData=function(e){if(!this.data){var i=this;t.ajax({method:"POST",dataType:"json",url:"/bitrix/tools/bizproc/user_selector.php",data:{ajax_action:"get_destination_data",sessid:t.bitrix_sessid(),site:t.message("SITE_ID")},onsuccess:function(t){i.data=t.data||{};if(e){e()}}})}else if(e){e()}};e.prototype={bind:function(){t.bind(this.bindTo,"click",this.onBindClick.bind(this));if(this.parentPopup){t.addCustomEvent(this.parentPopup,"onPopupClose",this.onParentPopupClose.bind(this))}},initDialog:function(){if(!e.canUse()){return false}if(this.inited){return true}var i={users:e.data.users||{},department:e.data.department||{},departmentRelation:e.data.departmentRelation||{}};var a={users:e.data.last.USERS||{}};if(!i["departmentRelation"]){i["departmentRelation"]=t.SocNetLogDestination.buildDepartmentRelation(i["department"])}var n=this.addCallback;t.SocNetLogDestination.init({name:this.id,showSearchInput:true,bindMainPopup:{node:this.bindTo,offsetTop:"5px",offsetLeft:"15px"},departmentSelectDisable:false,sendAjaxSearch:true,allowAddUser:false,extranetUser:false,useClientDatabase:false,items:i,itemsLast:a,itemsSelected:this.selected,destSort:e.data.destSort||{},callback:{select:function(e,i,a,s,o,d){if(d!=="select"){return}var r=e["id"];if(r.indexOf("U")===0)r=r.substr(1);if(r.indexOf("IU")===0)r=r.substr(2);var l={id:r,name:t.util.htmlspecialcharsback(e["name"]),title:t.util.htmlspecialcharsback(e["desc"]),photo:e["avatar"]};n(l);t.SocNetLogDestination.closeDialog()}}});return this.inited=true},onBindClick:function(){if(this.initDialog()){t.SocNetLogDestination.openDialog(this.id)}},onParentPopupClose:function(){if(this.inited){if(t.SocNetLogDestination.isOpenDialog()){t.SocNetLogDestination.closeDialog()}}}};return e}(window.BX||window.top.BX);