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/row.min.js |
(function(){"use strict";BX.namespace("BX.Report.Dashboard");BX.Report.Dashboard.Row=function(t){this.id=t.id;this.weight=t.weight||0;this.layoutMap=t.layoutMap||"";this.widgetsOrder=[];this.pseudo=t.pseudo||false;if(BX.type.isArray(t.widgets)){this.addWidgets(t.widgets)}this.draggable=t.draggable||true;this.loaded=t.loaded||false;this.timer=null;this.isScrollingUp=false;this.isScrollingDown=false;this.timer=null;this.rectArea=null;this.board={};this.rowLayout=new BX.Report.Dashboard.Row.LayoutFabric({row:this,map:this.layoutMap});this.layout={rowContainer:null,rowMoveControlButton:null,rowWrapper:null,rowAddButton:null,rowRemoveButton:null,controlsContainer:null,contentContainer:null,actionMenuOpenButton:null};this.pseudoRowsList=[]};BX.Report.Dashboard.Row.prototype={isPseudo:function(){return this.pseudo},removePseudo:function(){this.pseudo=false;if(this.isRendered()){this.getRowContainer().classList.remove("report-visualconstructor-dashboard-pseudo-row")}},getWidgetClass:function(t){var e=BX.Report.Dashboard.Utils.getClass(t);if(BX.type.isFunction(e)){return e}return BX.Report.Dashboard.Widget},getRowContainer:function(){if(this.layout.rowContainer){return this.layout.rowContainer}this.layout.rowContainer=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-row-container","data-id":this.getId(),"data-weight":this.getWeight(),"data-type":"row-container"}});if(this.isPseudo()){this.layout.rowContainer.classList.add("report-visualconstructor-dashboard-pseudo-row")}else{jsDD.registerDest(this.layout.rowContainer,31)}this.makeDraggable();return this.layout.rowContainer},getRowWrapper:function(){if(this.layout.rowWrapper){return this.layout.rowWrapper}this.layout.rowWrapper=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-row-wrapper","data-id":this.getId(),"data-type":"row-wrapper"}});return this.layout.rowWrapper},getRowMoveControlButton:function(){if(this.layout.rowMoveControlButton){return this.layout.rowMoveControlButton}this.layout.rowMoveControlButton=BX.create("div",{text:"^",props:{className:"report-visualconstructor-dashboard-row-move-control"}});return this.layout.rowMoveControlButton},getRowAddButton:function(){if(this.layout.rowAddButton){return this.layout.rowAddButton}this.layout.rowAddButton=BX.create("div",{text:"+",props:{className:"report-visualconstructor-dashboard-row-add-control"},events:{click:this.rowAddButtonClickHandler.bind(this)}});return this.layout.rowAddButton},getRowLayoutChooseContent:function(){var t=new BX.Report.Dashboard.Row.HorizontalLinear({row:this,cellCount:1});var e=new BX.Report.Dashboard.Row.HorizontalLinear({row:this,cellCount:2});var o=new BX.Report.Dashboard.Row.HorizontalLinear({row:this,cellCount:3});var r=new BX.Report.Dashboard.Row.HorizontalLinear({row:this,cellCount:4});return BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-row-miniature-popup-content"},children:[t.getMiniatureContainer(),e.getMiniatureContainer(),o.getMiniatureContainer(),r.getMiniatureContainer()]})},rowAddButtonClickHandler:function(){this.openRowLayoutChoosePopup()},openRowLayoutChoosePopup:function(){this.addRowPopup=new BX.PopupWindow("report-visualconstructor-dashboard-add-row-popup-"+this.getId(),this.getRowAddButton(),{title:"Select Row Layout",closeIcon:{right:"20px",top:"10px"},angle:true,autoHide:true,content:this.getRowLayoutChooseContent(),events:{onPopupClose:this.unpinRowAddButton.bind(this)}});this.addRowPopup.show();this.pinRowAddButton()},pinRowAddButton:function(){this.getRowAddButton().classList.add("report-visualconstructor-dashboard-add-row-popup-opened")},unpinRowAddButton:function(){this.getRowAddButton().classList.remove("report-visualconstructor-dashboard-add-row-popup-opened")},render:function(){var t=this.getRowContainer();var e=this.getRowWrapper();e.appendChild(this.getRowLayout().render());t.appendChild(e);t.appendChild(this.getRowMoveControlButton());t.appendChild(this.getRowAddButton());this.setRenderStatus(true);return t},getId:function(){return this.id},setId:function(t){if(this.isRendered()){this.getRowContainer().setAttribute("data-id",t);this.getRowWrapper().setAttribute("data-id",t)}this.id=t},getWeight:function(){return this.weight},setWeight:function(t){this.weight=t;if(this.isRendered()){this.getRowContainer().setAttribute("data-weight",t)}},getBoard:function(){return this.board},setBoard:function(t){this.board=t},getWidget:function(t){var e=t instanceof BX.Report.Dashboard.Widget?t.getId():t;for(var o=0;o<this.widgetsOrder.length;o++){if(this.widgetsOrder[o]instanceof BX.Report.Dashboard.Widget&&this.widgetsOrder[o].getId()===e){return this.widgetsOrder[o]}}return null},getWidgets:function(){return this.widgetsOrder},addWidget:function(t){var e;if(BX.type.isPlainObject(t)&&!(t instanceof BX.Report.Dashboard.Widget)){var o=this.getWidgetClass(t.className);e=new o(t)}else if(t instanceof BX.Report.Dashboard.Widget){e=t}else{throw new Error("Unable to create or get widget object")}e.setRowId(this.getId());e.setRow(this);this.widgetsOrder.push(e);if(this.isRendered()){if(!e.getCell()){var r=this.getRowLayout().getFirstEmptyCell();e.setCell(r)}e.getCell().setWidget(e)}return e},addWidgets:function(t){t.forEach(function(t){this.addWidget(t)}.bind(this))},moveWidget:function(t,e){if(e.getHeight()>t.getCell().getHeight()||t.getHeight()>e.getCell().getHeight()){return}if(!e.isDraggable()){return}var o=t.getCell();var r=e.getCell();var i=this.getRowLayout();var s=i.getCells();var a=null;if(t.getRow()===this){a=o}else{a=this.getRowLayout().getFirstEmptyCell()}if(a){var n=BX.util.array_search(a,s);var d=BX.util.array_search(r,s);r.getContainer().classList.add("report-visualconstructor-dashboard-empty-cell-droppable");r.getContainer().classList.add("report-visualconstructor-dashboard-empty-cell-droppable-active");var l=true;if(n>d){for(var h=n;h>d;h--){if(s[h-1].getWidget()&&s[h-1].getWidget().getHeight()<=s[h].getHeight()){s[h].setWidget(s[h-1].getWidget())}else{l=false;break}}if(l){r.clear();t.setCell(r)}}else{for(var u=n;u<d;u++){if(s[u+1].getWidget()&&s[u+1].getWidget().getHeight()<=s[u].getHeight()){s[u].setWidget(s[u+1].getWidget())}else{l=false;break}}if(l){r.clear();t.setCell(r)}}if(l){r.setHeight(t.getHeight());var g=BX.util.array_search(t,this.widgetsOrder);this.widgetsOrder.splice(g,1);var c=BX.util.array_search(e,this.widgetsOrder);if(c>=0){this.widgetsOrder.splice(c,0,t)}else{this.widgetsOrder.push(t)}}}},removeWidget:function(t){var e=BX.util.array_search(t,this.widgetsOrder);this.widgetsOrder.splice(e,1);if(this.getWidgets().length===0){this.getBoard().removeRow(this)}},remove:function(){this.destroy()},destroy:function(){jsDD.unregisterDest(this.layout.rowContainer);this.setRenderStatus(false);BX.remove(this.getRowContainer());this.getRowLayout().destroy()},getRowLayout:function(){return this.rowLayout},setRenderStatus:function(t){if(BX.type.isBoolean(t)){this.rendered=t}else{throw Error("Render status might be boolean")}},isRendered:function(){return this.rendered},isDraggable:function(){return this.draggable},makeDraggable:function(){if(!this.isDraggable()){return}this.getRowMoveControlButton().onbxdragstart=this.onDragStart.bind(this);this.getRowMoveControlButton().onbxdrag=this.onDrag.bind(this);this.getRowMoveControlButton().onbxdragstop=this.onDragStop.bind(this);jsDD.registerObject(this.getRowMoveControlButton())},onDragStart:function(){this.getRowContainer().classList.add("report-visualconstructor-dashboard-row-drag");this.dragRowOffset=jsDD.start_y;this.dragRowId=BX.util.array_search(this,this.getBoard().getRows());this.dragTargetRow=this.dragTargetRow||this},onDrag:function(t,e){this.verticalAutoScroll(e);this.moveVisuallyRows(e)},onDragStop:function(){var t=this.getBoard().moveRow(this,this.dragTargetRow);if(t){BX.onCustomEvent(this.getBoard(),"BX.Report.Dashboard.Board:afterRowMoved",[this.getBoard().getRows()])}this.getRowContainer().classList.remove("report-visualconstructor-dashboard-row-drag");var e=this.getBoard().getRows();for(var o in e){if(!e.hasOwnProperty(o)){continue}var r=e[o];var i=r.getRowContainer();r.resetRectArea();i.style.removeProperty("transition");i.style.removeProperty("transform")}this.stopScroll()},getRectArea:function(){this.rectArea=BX.pos(this.getRowContainer());this.rectArea.middle=this.rectArea.top+this.rectArea.height/2;return this.rectArea},moveVisuallyRows:function(t){this.getRowContainer().style.transform="translateY("+(t-this.dragRowOffset)+"px)";var e=this.getBoard().getRows();var o=this.getRectArea().height;var r;for(var i in e){if(!e.hasOwnProperty(i)){continue}var s=e[i];if(s===this){continue}var a=s.getRowContainer();var n=s.getRectArea();var d=n.middle;if(t>d&&i>this.dragRowId&&a.style.transform!=="translateY("+-o+"px)"){r=this.getWeight();this.setWeight(s.getWeight());s.setWeight(r);a.style.transition="300ms";a.style.transform="translateY("+-o+"px)";this.dragTargetRow=this.getBoard().getNextRowSibling(s);s.resetRectArea()}if(t<d&&i<this.dragRowId&&a.style.transform!=="translateY("+o+"px)"){r=this.getWeight();this.setWeight(s.getWeight());s.setWeight(r);a.style.transition="300ms";a.style.transform="translateY("+o+"px)";this.dragTargetRow=s;s.resetRectArea()}var l=t<d&&i>this.dragRowId&&a.style.transform!==""&&a.style.transform!=="translateY(0px)";var h=t>d&&i<this.dragRowId&&a.style.transform!==""&&a.style.transform!=="translateY(0px)";if(l||h){a.style.transition="300ms";a.style.transform="translateY(0px)";this.dragTargetRow=l?s:this.getBoard().getNextRowSibling(s);s.resetRectArea()}}},resetRectArea:function(){this.rectArea=null},lazyLoadWidgets:function(){if(!this.loaded){var t=this.getWidgets();t.forEach(function(t){t.lazyLoad()});this.loaded=true}},verticalAutoScroll:function(t){var e=window.pageYOffset||document.documentElement.scrollTop;var o=document.documentElement.clientHeight;var r=t-e;if(r>=o-50){this.scrollDown(t)}else if(r<=50){this.scrollUp(t)}else{this.stopScroll()}},scrollUp:function(t){if(this.isScrollingUp){return}this.isScrollingUp=true;this.timer=setInterval(function(){var e=window.pageYOffset||document.documentElement.scrollTop;window.scrollTo(0,e-10);t-=10;this.moveVisuallyRows(t)}.bind(this),20)},scrollDown:function(t){if(this.isScrollingDown){return}this.isScrollingDown=true;this.timer=setInterval(function(){var e=window.pageYOffset||document.documentElement.scrollTop;window.scrollTo(0,e+10);t+=10;this.moveVisuallyRows(t)}.bind(this),20)},stopScroll:function(){this.isScrollingUp=false;this.isScrollingDown=false;clearInterval(this.timer)},removeTopPseudoRows:function(){for(var t=0;t<this.pseudoRowsList.top.length;t++){if(this.pseudoRowsList.top[t]instanceof BX.Report.Dashboard.Row&&this.pseudoRowsList.top[t].isPseudo()){this.getBoard().removeRow(this.pseudoRowsList.top[t])}}this.pseudoRowsList.top=[]},removeBottomPseudoRows:function(){for(var t=0;t<this.pseudoRowsList.bottom.length;t++){if(this.pseudoRowsList.bottom[t]instanceof BX.Report.Dashboard.Row&&this.pseudoRowsList.bottom[t].isPseudo()){this.getBoard().removeRow(this.pseudoRowsList.bottom[t])}}this.pseudoRowsList.bottom=[]}}})(); //# sourceMappingURL=row.map.js