%PDF- %PDF-
Direktori : /home/bitrix/www/bitrix/components/bitrix/main.ui.selector/templates/.default/ |
Current File : //home/bitrix/www/bitrix/components/bitrix/main.ui.selector/templates/.default/script.min.js |
(function(){"use strict";BX.namespace("BX.Main");BX.Main.selectorManager={getById:function(t){if(typeof this.controls[t]!="undefined"){return this.controls[t]}return null},controls:{}};BX.Main.Selector=function(){this.initialized=false;this.blockInit=false;this.id="";this.inputId=null;this.input=null;this.tagId=null;this.tag=null;this.options=null;this.callback=null;this.items=null;this.entities=null;this.mainPopupWindow=null;this.entitiesSet=["users","emails","crmemails","groups","sonetgroups","department","departmentRelation","contacts","companies","leads","deals"];this.auxObject=null};BX.Main.Selector.controls={};BX.Main.Selector.create=function(t){if(typeof t.id=="undefined"||!t.id){t.id=BX.util.hashCode(Math.random().toString())}else if(typeof BX.Main.selectorManager.controls[t.id]!="undefined"){return BX.Main.selectorManager.controls[t.id]}var e=new BX.Main.Selector;e.init(t);BX.Main.selectorManager.controls[e.getId()]=e;return e};BX.Main.Selector.proxyCallback=function(t,e){t(e)};BX.Main.Selector.prototype={init:function(t){try{if(!("SocNetLogDestination"in BX)){throw new ReferenceError("No BX.SocNetLogDestination detected. Forgot to include socialnetwork module and/or its assets?")}}catch(t){throw t}this.id=t.id;this.inputId=t.inputId?t.inputId:null;this.input=t.inputId&&BX(t.inputId)?BX(t.inputId):null;this.containerNode=t.containerId&&BX(t.containerId)?BX(t.containerId):null;this.bindNode=t.bindId&&BX(t.bindId)?BX(t.bindId):this.containerNode;this.tagId=t.tagId?t.tagId:null;this.tag=t.tagId&&BX(t.tagId)?BX(t.tagId):null;this.openDialogWhenInit=typeof t.openDialogWhenInit=="undefined"||!!t.openDialogWhenInit;this.options=t.options||{};this.callback=t.callback||null;this.items=t.items||null;this.entities=t.entities||null;var e={name:this.id,pathToAjax:t.pathToAjax?t.pathToAjax:null,searchInput:this.input||null,bindMainPopup:{node:this.bindNode,offsetTop:"5px",offsetLeft:"15px"},bindSearchPopup:{node:this.bindNode,offsetTop:"5px",offsetLeft:"15px"},userSearchArea:this.getOption("userSearchArea"),lazyLoad:this.getOption("lazyLoad")=="Y",useClientDatabase:this.getOption("useClientDatabase")=="Y",sendAjaxSearch:this.getOption("sendAjaxSearch")!="N",showSearchInput:this.getOption("useSearch")=="Y",allowAddUser:this.getOption("allowAddUser")=="Y",allowAddCrmContact:this.getOption("allowAddCrmContact")=="Y",allowAddSocNetGroup:this.getOption("allowAddSocNetGroup")=="Y",allowSearchEmailUsers:this.getOption("allowSearchEmailUsers")=="Y",allowSearchCrmEmailUsers:this.getOption("allowSearchCrmEmailUsers")=="Y",allowSearchNetworkUsers:this.getOption("allowSearchNetworkUsers")=="Y",enableDepartments:this.getOption("enableDepartments")=="Y",departmentSelectDisable:this.getOption("departmentSelectDisable")=="Y",enableSonetgroups:this.getOption("enableSonetgroups")=="Y",enableProjects:this.getOption("enableProjects")=="Y",isCrmFeed:this.getOption("isCrmFeed")=="Y",callback:{select:this.callback.select!=null?BX.delegate(function(t,e,i,n,o,a){this.getOption("useNewCallback")=="Y"?BX.Main.Selector.proxyCallback(this.callback.select,{name:o,item:t,type:e,search:i,bUndeleted:n,state:a}):this.callback.select(t,e,i,n,o,a)},this):null,unSelect:this.callback.unSelect!=null?BX.delegate(function(t,e,i,n){this.getOption("useNewCallback")=="Y"?BX.Main.Selector.proxyCallback(this.callback.unSelect,{name:n,item:t,type:e,search:i}):this.callback.unSelect(t,e,i,n)},this):null,openDialog:this.callback.openDialog!=null?BX.delegate(function(t){this.getOption("useNewCallback")=="Y"?BX.Main.Selector.proxyCallback(this.callback.openDialog,{name:t}):this.callback.openDialog(t)},this):null,closeDialog:this.callback.closeDialog!=null?BX.delegate(function(t){this.getOption("useNewCallback")=="Y"?BX.Main.Selector.proxyCallback(this.callback.closeDialog,{name:t}):this.callback.closeDialog(t)},this):null,openSearch:this.callback.openSearch!=null?BX.delegate(function(t){this.getOption("useNewCallback")=="Y"?BX.Main.Selector.proxyCallback(this.callback.openSearch,{name:t}):this.callback.openSearch(t)},this):null,closeSearch:this.callback.closeSearch!=null?BX.delegate(function(t){this.getOption("useNewCallback")=="Y"?BX.Main.Selector.proxyCallback(this.callback.closeSearch,{name:t}):this.callback.closeSearch(t)},this):null,openEmailAdd:this.callback.openEmailAdd!=null?BX.delegate(function(t){this.getOption("useNewCallback")=="Y"?BX.Main.Selector.proxyCallback(this.callback.openEmailAdd,{name:t}):this.callback.openEmailAdd(t)},this):null,closeEmailAdd:this.callback.closeEmailAdd!=null?BX.delegate(function(t){this.getOption("useNewCallback")=="Y"?BX.Main.Selector.proxyCallback(this.callback.closeEmailAdd,{name:t}):this.callback.closeEmailAdd(t)},this):null},allowSonetGroupsAjaxSearchFeatures:this.getOption("allowSonetGroupsAjaxSearchFeatures")};var i=null;e.items={};for(var n=0;n<this.entitiesSet.length;n++){i=this.entitiesSet[n];e.items[i]=this.entities[i]||{}}e.itemsLast={};e.itemsSelected=this.items.selected||{};BX.SocNetLogDestination.init(e);if(this.input){if(!this.options.lazyLoad){this.initDialog()}if(this.tag){BX.bind(this.tag,"focus",BX.delegate(function(t){this.initDialog({realParams:true,bByFocusEvent:true});return BX.PreventDefault(t)},this));BX.SocNetLogDestination.BXfpSetLinkName({formName:this.id,tagInputName:t.tagId,tagLink1:BX.message("BX_FPD_LINK_1"),tagLink2:BX.message("BX_FPD_LINK_2")})}BX.bind(this.input,"keydown",BX.proxy(BX.SocNetLogDestination.BXfpSearchBefore,{formName:this.id,inputName:t.inputId}));this.auxObject={formName:this.id,inputNode:BX(t.inputId),tagInputName:t.tagId};BX.bind(this.input,"bxchange",BX.proxy(BX.SocNetLogDestination.BXfpSearch,this.auxObject));this.input.setAttribute("data-bxchangehandler","Y")}else if(e.showSearchInput){if(!this.options.lazyLoad){this.initDialog()}}if(this.items.hidden){for(var o in this.items.hidden){if(this.items.hidden.hasOwnProperty(o)){this.callback.select.apply({id:(typeof this.items.hidden[o]["PREFIX"]!="undefined"?this.items.hidden[o]["PREFIX"]:"SG")+this.items.hidden[o]["ID"],name:this.items.hidden[o]["NAME"]},typeof this.items.hidden[o]["TYPE"]!="undefined"?this.items.hidden[o]["TYPE"]:"sonetgroups","",true,"","init")}}}},show:function(){this.initDialog()},initDialog:function(t){if(typeof t=="undefined"||typeof t.realParams=="undefined"){t=null}if(this.blockInit){return}var e={id:this.id};if(!this.initialized){BX.onCustomEvent(window,"BX.Main.Selector:beforeInitDialog",[e])}setTimeout(BX.delegate(function(){if(typeof e.blockInit=="undefined"||e.blockInit!==true){if(this.initialized){if(!this.mainPopupWindow||!this.mainPopupWindow.isShown()){this.openDialog(t)}}else{this.getData(BX.delegate(function(e){if(!!this.openDialogWhenInit){this.openDialog(t)}BX.onCustomEvent(window,"BX.Main.Selector:afterInitDialog",[{id:this.id}]);if(typeof this.options.eventOpen!="undefined"){BX.addCustomEvent(window,this.options.eventOpen,BX.delegate(function(t){if(typeof t.id=="undefined"||t.id!=this.id){return}if(t.bindNode){var e=BX.findChild(t.bindNode,{tagName:"input",attr:{type:"text"}},true);if(e){BX.bind(e,"keydown",BX.proxy(BX.SocNetLogDestination.BXfpSearchBefore,{formName:this.id,inputName:null,inputNode:e}));this.auxObject={formName:this.id,inputNode:e,tagInputName:t.tagId};BX.SocNetLogDestination.obElementBindMainPopup[this.id].node=e;BX.SocNetLogDestination.obElementBindSearchPopup[this.id].node=e;if(e.getAttribute("data-bxchangehandler")!=="Y"){BX.bind(e,"bxchange",BX.proxy(BX.SocNetLogDestination.BXfpSearch,this.auxObject));BX.SocNetLogDestination.obItemsSelected[this.id]={};e.setAttribute("data-bxchangehandler","Y")}if(typeof t.value!="undefined"){BX.SocNetLogDestination.obItemsSelected[this.id]=t.value}}this.openDialog({bindNode:t.bindNode})}},this))}},this))}}},this),1)},openDialog:function(t){BX.SocNetLogDestination.openDialog(this.id,t);this.mainPopupWindow=BX.SocNetLogDestination.popupWindow},closeDialog:function(){BX.SocNetLogDestination.closeDialog()},getData:function(t){this.blockInit=true;BX.ajax({url:"/bitrix/components/bitrix/main.ui.selector/ajax.php",method:"POST",dataType:"json",data:{sessid:BX.bitrix_sessid(),site:BX.message("SITE_ID"),options:this.options,action:"getData"},onsuccess:BX.delegate(function(e){this.blockInit=false;if(!!e.SUCCESS){this.addData(e.DATA,t);this.initialized=true}},this),onfailure:BX.delegate(function(t){this.blockInit=false},this)})},addData:function(t,e){function i(t,e){if(typeof e!="undefined"){if(typeof t=="undefined"){t={}}for(var i in e){if(e.hasOwnProperty(i)){t[i]=e[i]}}}}i(BX.SocNetLogDestination.obItems[this.id]["groups"],t.ITEMS.GROUPS);i(BX.SocNetLogDestination.obItems[this.id]["users"],t.ITEMS.USERS);i(BX.SocNetLogDestination.obItems[this.id]["emails"],t.ITEMS.EMAILS);i(BX.SocNetLogDestination.obItems[this.id]["crmemails"],t.ITEMS.CRMEMAILS);i(BX.SocNetLogDestination.obItems[this.id]["sonetgroups"],t.ITEMS.SONETGROUPS);i(BX.SocNetLogDestination.obItems[this.id]["department"],t.ITEMS.DEPARTMENT);BX.SocNetLogDestination.obItems[this.id]["departmentRelation"]=BX.SocNetLogDestination.buildDepartmentRelation(BX.SocNetLogDestination.obItems[this.id]["department"]);BX.SocNetLogDestination.obItemsLast[this.id]["users"]=typeof t["ITEMS_LAST"]["USERS"]!="undefined"?t["ITEMS_LAST"]["USERS"]:{};BX.SocNetLogDestination.obItemsLast[this.id]["emails"]=typeof t["ITEMS_LAST"]["EMAILS"]!="undefined"?t["ITEMS_LAST"]["EMAILS"]:{};BX.SocNetLogDestination.obItemsLast[this.id]["crmemails"]=typeof t["ITEMS_LAST"]["CRMEMAILS"]!="undefined"?t["ITEMS_LAST"]["CRMEMAILS"]:{};BX.SocNetLogDestination.obItemsLast[this.id]["sonetgroups"]=typeof t["ITEMS_LAST"]["SONETGROUPS"]!="undefined"?t["ITEMS_LAST"]["SONETGROUPS"]:{};BX.SocNetLogDestination.obItemsLast[this.id]["department"]=typeof t["ITEMS_LAST"]["DEPARTMENT"]!="undefined"?t["ITEMS_LAST"]["DEPARTMENT"]:{};BX.SocNetLogDestination.obItemsLast[this.id]["groups"]=typeof t["ITEMS_LAST"]["GROUPS"]!="undefined"?t["ITEMS_LAST"]["GROUPS"]:{};if(typeof t.ITEMS_LAST.CRM!="undefined"&&t.ITEMS_LAST.CRM.length>0){BX.SocNetLogDestination.obCrmFeed[this.id]=true}if(typeof t.SONETGROUPS_LIMITED!="undefined"&&t.SONETGROUPS_LIMITED=="Y"){BX.SocNetLogDestination.obAllowSonetGroupsAjaxSearch[this.id]=true}BX.SocNetLogDestination.obDestSort[this.id]=t.DEST_SORT;e.apply(this,t)},getId:function(){return this.id},getOption:function(t){return typeof this.options[t]!="undefined"?this.options[t]:null}}})();