Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/accessrights/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/accessrights/section.min.js |
(function(){"use strict";BX.namespace("BX.UI");BX.UI.AccessRights.Section=function(t){this.id=t.id?t.id:null;this.headSection=t.headSection?t.headSection:null;this.title=t.title;this.rights=t.rights?t.rights:[];this.userGroups=t.userGroups?t.userGroups:[];this.grid=t.grid?t.grid:null;this.layout={title:null,headColumn:null,columns:null,content:null,earLeft:null,earRight:null};this.scroll=0;this.earTimer=null;this.earLeftTimer=null;this.earRightTimer=null;this.columns=[];this.bindEvents()};BX.UI.AccessRights.Section.prototype={bindEvents:function(){BX.addCustomEvent("AccessRights.Section:scrollLeft",function(t){if(this.title!==t.title){this.getColumnsContainer().scrollLeft=t.getScroll()}t.adjustEars();BX.PopupMenu.destroy("ui-access-rights-column-item-popup-variables")}.bind(this));BX.addCustomEvent("AccessRights.Section:scrollRight",function(t){if(this.title!==t.title){this.getColumnsContainer().scrollLeft=t.getScroll()}t.adjustEars();BX.PopupMenu.destroy("ui-access-rights-column-item-popup-variables")}.bind(this));BX.bind(window,"resize",this.adjustEars.bind(this))},getGrid:function(){return this.grid},addColumn:function(t){if(!t){return}var e=Object.assign({},t);e.userGroup=t;var i=this.getColumn(e);this.layout.columns.appendChild(i.render());this.columns.push(i)},removeColumn:function(t){if(!t){return}for(var e=0;e<this.columns.length;e++){if(t.userGroup===this.columns[e].userGroup){this.columns[e].remove();break}}},getColumn:function(t){var e=[];this.rights.map(function(t){e.push({type:t.type,title:t.type==="variables"?t.title:null,hint:t.hint,variables:t.type==="variables"?t.variables:[],access:t})}.bind(this));return new BX.UI.AccessRights.Column({items:e,userGroup:t.userGroup?t.userGroup:null,section:this,headSection:t.headSection,grid:this.grid,newColumn:t.newColumn?t.newColumn:null})},addHeadColumn:function(){var t=[];if(!this.headSection){this.rights.map(function(e){t.push({id:e.id,type:"title",title:e.title,hint:e.hint})}.bind(this))}if(this.headSection){t=[{type:"userGroupTitle",title:BX.message("JS_UI_ACCESSRIGHTS_ROLES"),controller:true},{type:"userGroupTitle",title:BX.message("JS_UI_ACCESSRIGHTS_EMPLOYEES_AND_DEPARTMENTS"),controller:false}]}var e=new BX.UI.AccessRights.Column({items:t,section:this,grid:this.grid});this.layout.headColumn.appendChild(e.render())},getTitle:function(){return BX.create("div",{props:{className:"ui-access-rights-section-title"},text:this.title})},getMainContainer:function(){return BX.create("div",{props:{className:"ui-access-rights-section-container"},children:[this.layout.headColumn=BX.create("div",{props:{className:"ui-access-rights-section-head"}}),this.getContentContainer()]})},getColumnsContainer:function(){if(!this.layout.columns){this.layout.columns=BX.create("div",{props:{className:"ui-access-rights-section-wrapper"},events:{scroll:this.adjustScroll.bind(this)}})}return this.layout.columns},getContentContainer:function(){if(!this.layout.content){this.layout.content=BX.create("div",{props:{className:"ui-access-rights-section-content"},children:[this.getColumnsContainer(),this.getEarLeft(),this.getEarRight()]})}return this.layout.content},getEarLeft:function(){var t=this;if(!this.layout.earLeft){this.layout.earLeft=BX.create("div",{props:{className:"ui-access-rights-section-ear-left"},events:{mouseenter:function(){t.stopAutoScroll();t.earLeftTimer=setTimeout(function(){t.scrollToLeft()},110)},mouseleave:function(){clearTimeout(t.earLeftTimer);t.stopAutoScroll()}}})}return this.layout.earLeft},getEarRight:function(){var t=this;if(!this.layout.earRight){this.layout.earRight=BX.create("div",{props:{className:"ui-access-rights-section-ear-right"},events:{mouseenter:function(){t.stopAutoScroll();t.earRightTimer=setTimeout(function(){t.scrollToRight()},110)},mouseleave:function(){clearTimeout(t.earRightTimer);t.stopAutoScroll()}}})}return this.layout.earRight},adjustEars:function(){var t=this.getColumnsContainer();var e=t.scrollLeft;var i=e>0;var s=t.scrollWidth>Math.round(e+t.offsetWidth);this.getContentContainer().classList[i?"add":"remove"]("ui-access-rights-section-ear-left-shown");this.getContentContainer().classList[s?"add":"remove"]("ui-access-rights-section-ear-right-shown")},scrollToRight:function(t,e){var i=20;t?i=2:null;this.earTimer=setInterval(function(){this.getColumnsContainer().scrollLeft+=10;if(t){t<=this.getColumnsContainer().scrollLeft?this.stopAutoScroll():null}}.bind(this),i);if(e==="stop"){setTimeout(function(){clearTimeout(this.earTimer);this.getGrid().unlock()}.bind(this),t*2)}},scrollToLeft:function(){this.earTimer=setInterval(function(){this.getColumnsContainer().scrollLeft-=10}.bind(this),20)},stopAutoScroll:function(){clearInterval(this.earTimer);BX.onCustomEvent(window,"BX.UI.AccessRights.Grid:stopAutoScroll",this)},adjustScroll:function(){if(this.scroll<this.getColumnsContainer().scrollLeft){this.scroll=this.getColumnsContainer().scrollLeft;BX.onCustomEvent("AccessRights.Section:scrollRight",[this])}if(this.scroll>this.getColumnsContainer().scrollLeft){this.scroll=this.getColumnsContainer().scrollLeft;BX.onCustomEvent("AccessRights.Section:scrollLeft",[this])}},getScroll:function(){return this.scroll},render:function(){var t=BX.create("div",{props:{className:"ui-access-rights-section"},children:[this.title?this.getTitle():null,this.getMainContainer()]});this.addHeadColumn();var e=document.createDocumentFragment();for(var i=0;i<this.grid.getUserGroups().length;i++){var s=this.getColumn({headSection:this.headSection?this.headSection:null,userGroup:this.grid.getUserGroups()[i]});this.columns.push(s);e.appendChild(s.render())}this.getColumnsContainer().appendChild(e);return t}}})(); //# sourceMappingURL=section.map.js