Current Path : /var/www/u0635749/data/www/hobbyclick.ru/public/www/bitrix/js/report/js/dashboard/ |
Current File : /var/www/u0635749/data/www/hobbyclick.ru/public/www/bitrix/js/report/js/dashboard/rowlayouts.min.js |
(function(){"use strict";BX.namespace("BX.Report.Dashboard.Row");BX.Report.Dashboard.Row.BaseLayout=function(e){this.cellCount=e.cellCount;this.row=e.row;this.cells=[]};BX.Report.Dashboard.Row.BaseLayout.prototype={getClassName:function(){return"BX.Report.Dashboard.Row.BaseLayout"},getRow:function(){return this.row},getWidgets:function(){return this.getRow().getWidgets()},getCells:function(){return this.cells},getFirstEmptyCell:function(){var e=this.getCells();for(var t=1;t<=e.length;t++){if(e[t]instanceof BX.Report.Dashboard.Cell&&e[t].isEmpty()){return e[t]}}return null},getMiniatureContainer:function(){var e=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-miniature-container"},events:{click:this.handlerRowAddByMiniature.bind(this)}});for(var t=1;t<=this.cellCount;t++){var l=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-miniature-cell"}});e.appendChild(l)}return e},getPseudoRowId:function(){return"pseudo_"+Math.floor(Math.random()*(99999-15e3))+15e3+""},getPseudoCellId:function(){return"js_"+BX.util.getRandomString()},handlerRowAddByMiniature:function(){this.getRow().getBoard().addRow(new BX.Report.Dashboard.Row({id:this.getPseudoRowId(),pseudo:true,maxWidgetCount:""+this.cellCount,layoutMap:this.getLayoutMap()}),this.getRow(),false);this.getRow().addRowPopup.close()},getLayoutMap:function(){var e=[];for(var t=1;t<=this.cellCount;t++){var l={type:"cell",id:this.getPseudoCellId(),removable:0};e.push(l)}return{type:"cell-container",orientation:"horizontal",elements:e}}};BX.Report.Dashboard.Row.HorizontalLinear=function(e){BX.Report.Dashboard.Row.BaseLayout.apply(this,arguments)};BX.Report.Dashboard.Row.HorizontalLinear.prototype={__proto__:BX.Report.Dashboard.Row.BaseLayout.prototype,constructor:BX.Report.Dashboard.Row.HorizontalLinear,getClassName:function(){return"BX.Report.Dashboard.Row.HorizontalLinear"}};BX.Report.Dashboard.Row.LayoutFabric=function(e){this.row=e.row;this.map=e.map;this.layout=null;this.cells=[]};BX.Report.Dashboard.Row.LayoutFabric.prototype={render:function(){var e=this.getLayout();this.fillCellsWithWidgets();return e},getRow:function(){return this.row},getCells:function(){return this.cells},getWidgets:function(){return this.getRow().getWidgets()},getMapWithoutDomElements:function(e,t){if(!t){e=this.getMap()}var l={};if(e["type"]==="cell-container"){l["type"]=e["type"];l["orientation"]=e["orientation"];l["elements"]=[];for(var r in e["elements"]){l["elements"].push(this.getMapWithoutDomElements(e["elements"][r],true))}}else if(e["type"]==="cell"){l["type"]=e["type"];l["id"]=e["id"];l["flexValue"]=e["flexValue"];l["height"]=e["height"]}return l},getMap:function(){return this.map},getFirstEmptyCell:function(){var e=this.getCells();for(var t=0;t<=e.length;t++){if(e[t]instanceof BX.Report.Dashboard.Cell&&e[t].isEmpty()){return e[t]}}return null},getLayout:function(){if(this.layout){return this.layout}this.layout=this.buildNestedCellNodeTree(this.getMap(),false);return this.layout},destroy:function(){BX.remove(this.getLayout());var e=this.getCells();for(var t=0;t<e.length;t++){e[t].destroy()}},fillCellsWithWidgets:function(){var e=this.getWidgets();var t=this.getCells();BX.Report.Dashboard.Utils.forEach(e,function(l){for(var r=0;r<t.length;r++){var n=e[l].getWeight();if(n===t[r].getId()&&t[r].isEmpty()){t[r].setWidget(e[l])}}}.bind(this))},buildNestedCellNodeTree:function(e,t){if(e["type"]==="cell"){var l=new BX.Report.Dashboard.Cell({id:e["id"],height:e["height"]||380,flexValue:e["flexValue"]||1,row:this.getRow()});this.cells.push(l);var r=l.render();e["domElement"]=r;return r}if(e["type"]==="cell-container"){var n;if(e["orientation"]==="horizontal"){n=this.getCellRowContainer()}else if(e["orientation"]==="vertical"){n=this.getCellColumnContainer()}if(e["elements"]){for(var i=0;i<e["elements"].length;i++){n.appendChild(this.buildNestedCellNodeTree(e["elements"][i],true))}}if(t){var o=this.getCellContainer();o.style.flex=e["flexValue"]||1;o.appendChild(n);e["domElement"]=o;return o}else{e["domElement"]=n;return n}}},getCellContainer:function(){return BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-cell report-visualconstructor-dashboard-cell-container","data-type":"cell-container"}})},getCellRowContainer:function(){return BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-row report-visualconstructor-dashboard-row-direction-row"}})},getCellColumnContainer:function(){return BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-row report-visualconstructor-dashboard-row-direction-column"}})},transformCellToContainer:function(e,t){var l=this.findContainerContainsCell(e,this.getMap());var r=this.findCellIndexInContainerElements(e,l["elements"]);var n=l["elements"][r]["domElement"];var i=Object.assign({},l["elements"][r]);var o=this.getPseudoCellId();i.flexValue=1;i.height=380;var a=[i];for(var s=1;s<t.cellCount;s++){a.push({type:"cell",id:o,height:180,flexValue:1,removable:1})}l["elements"][r]={type:"cell-container",flexValue:l["elements"][r]["flexValue"]||1,orientation:t["orientation"],elements:a};var u=BX.util.array_search(e,this.getCells());this.cells.splice(u,1);var d=this.buildNestedCellNodeTree(l["elements"][r],true);l["domElement"].replaceChild(d,n);this.fillCellsWithWidgets()},findContainerContainsCell:function(e,t){var l=t;if(l["type"]==="cell-container"){for(var r=0;r<l["elements"].length;r++){if(l["elements"][r]["type"]==="cell-container"){var n=this.findContainerContainsCell(e,l["elements"][r]);if(n){return n}}if(l["elements"][r]["type"]==="cell"){if(e.getId()===l["elements"][r]["id"]){return t}}}}return null},findCellIndexInContainerElements:function(e,t){for(var l=0;l<t.length;l++){if(t[l]["id"]===e.getId()){return l}}return null},getCellById:function(e){var t=this.getCells();for(var l=0;l<t.length;l++){if(t[l].getId()===e){return t[l]}}return false},adjustNoEmptyCellsInCellLevel:function(e){var t=this.findContainerContainsCell(e,this.getMap());var l=this.findCellIndexInContainerElements(e,t["elements"]);var r=t["elements"][l];for(var n=0;n<t["elements"].length;n++){if(t["elements"][n]["type"]==="cell"){var i=this.getCellById(t["elements"][n]["id"]);if(i.getId()!==r["id"]&&!i.isEmpty()){var o=i.getContainer().clientHeight;var a=i.getWidget().getHeight();var s=Math.round(o/a);if(s>1){this.transformCellToContainer(i,{orientation:"vertical",cellCount:2})}}}}},adjustCellToMaxSize:function(e){var t=this.findContainerContainsCell(e,this.getMap());if(t["orientation"]==="vertical"){if(!this.isCellsContainerHasFilledCell(t)){this.clearCellsFromCollectionByContainer(t);var l=t.domElement;t.type="cell";t.flexValue=1;t.id=this.getPseudoCellId();delete t.orientation;delete t.elements;var r=this.buildNestedCellNodeTree(t,false);this.getLayout().replaceChild(r,l);t.domElement=r}}},clearCellsFromCollectionByContainer:function(e){if(e["type"]==="cell-container"){for(var t=0;t<e["elements"].length;t++){if(e["elements"][t]["type"]==="cell"){var l=this.getCellById(e["elements"][t]["id"]);var r=BX.util.array_search(l,this.getCells());this.cells.splice(r,1)}else{this.clearCellsFromCollectionByContainer(e["elements"][t])}}}},isCellsContainerHasFilledCell:function(e){for(var t=0;t<e["elements"].length;t++){if(e["elements"][t]["type"]==="cell"){var l=this.getCellById(e["elements"][t]["id"]);if(!l.isEmpty()){return true}}}return false},getPseudoCellId:function(){return"js_"+BX.util.getRandomString()}}})(); //# sourceMappingURL=rowlayouts.map.js