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/widget.min.js |
(function(){BX.namespace("BX.Report.Dashboard");BX.Report.Dashboard.Widget=function(t){this.id=t.id;this.rowId=t.rowId;this.title=t.title||"No title";this.weight=t.weight||0;this.data=t.data||{};this.isHeadEnabled=t.isHeadEnabled!==false;this.setContent(t.content||null);this.width=t.width||"100%";this.height=t.height||"100%";this.draggable=t.draggable||false;this.droppable=t.droppable||false;this.loaded=t.loaded||false;this.cell=t.cell||null;this.config=t.config||null;this.resizable=t.resizable;this.dropped=false;this.layout={lazyLoadPresetContainer:null,widgetContainer:null,widgetWrapper:null,headContainer:null,headWrapper:null,titleContainer:null,controlsContainer:null,contentContainer:null,contentWrapper:null,menuOpenButton:null};this.actionItems=t.actionItems||[];this.events=t.events||{};this.actionItems.push(BX.create("div",{text:BX.message("DASHBOARD_WIDGET_REMOVE_TITLE"),events:{click:this.openDeleteConfirmPopup.bind(this)}}));this.board=null};BX.Report.Dashboard.Widget.prototype={isResizeable:function(){return this.resizable},isDarkMode:function(){var t=this.getColor().substring(1,7);return BX.Report.Dashboard.Utils.isDarkColor(t)},getColor:function(){return this.config.color?this.config.color:"#ffffff"},setColor:function(t){this.config.color=t},applyColor:function(){if(this.loaded){this.getWidgetWrapper().style.backgroundColor=this.getColor();if(this.isDarkMode()){this.getWidgetWrapper().classList.add("report-visualconstructor-dashboard-widget-dark");this.getWidgetWrapper().classList.remove("report-visualconstructor-dashboard-widget-light")}else{this.getWidgetWrapper().classList.add("report-visualconstructor-dashboard-widget-light");this.getWidgetWrapper().classList.remove("report-visualconstructor-dashboard-widget-dark")}}},getLazyLoadPresetContainer:function(){if(this.layout.lazyLoadPresetContainer){return this.layout.lazyLoadPresetContainer}var t=this.runtimeContent.renderPreview();if(t){this.layout.lazyLoadPresetContainer=t}else{var e=new BX.Loader({size:60});this.layout.lazyLoadPresetContainer=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-widget-lazy-load-preset"}});e.show(this.layout.lazyLoadPresetContainer)}return this.layout.lazyLoadPresetContainer},getWidgetContainer:function(){if(this.layout.widgetContainer){return this.layout.widgetContainer}this.layout.widgetContainer=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-widget-container","data-id":this.getId(),"data-weight":this.getWeight(),"data-type":"widget"}});this.makeDraggable(this.layout.widgetContainer);return this.layout.widgetContainer},getWidgetWrapper:function(){var t=null;if(this.layout.widgetWrapper){return this.layout.widgetWrapper}else{t=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-widget-wrapper"}})}this.layout.widgetWrapper=t;return this.layout.widgetWrapper},makeDraggable:function(t){if(!this.isDraggable()){return}this.getWidgetContainer().classList.add("report-visualconstructor-dashboard-draggable-widget-container");t.onbxdragstart=this.onDragStart.bind(this);t.onbxdrag=this.onDrag.bind(this);t.onbxdragstop=this.onDragStop.bind(this);t.onbxdragfinish=this.onDragFinish.bind(this);t.onbxdragrelease=this.onDragEnd.bind(this);jsDD.registerObject(t)},isDraggable:function(){return this.draggable},onDragStart:function(){if(!this.dragElement){this.dropped=false;var t=this.getWidgetContainer();this.dragElement=t.cloneNode(true);this.dragElement.rotated=false;this.dragWidgetOffsetX=jsDD.start_x-this.getRectArea().left;this.dragWidgetOffsetY=jsDD.start_y-this.getRectArea().top;this.dragElement.style.position="absolute";this.dragElement.style.height=this.getRectArea().height+"px";this.dragElement.style.width=this.getRectArea().width+"px";this.dragElement.style.flex="none";this.dragElement.classList.add("report-visualconstructor-dashboard-widget-drag");document.body.appendChild(this.dragElement);this.getCell().clear();this.getCell().getContainer().style.height=this.getRectArea().height+"px"}},onDrag:function(t,e){if(this.dragElement){this.autoResize();this.rotateDragWidget(t,e);this.autoScroll(t,e);this.moveDragWidget(t,e);this.getRow().getBoard().showPriorityPseudoRowsByYPos(this.buildPriorityRows(),e)}},buildPriorityRows:function(){var t=[];t[0]=this.getSingleCellRow();if(this.isResizeable()){t[1]=this.getDoubledPriorityRow()}return t},getSingleCellRow:function(){return new BX.Report.Dashboard.Row({id:"js_"+BX.util.getRandomString(),pseudo:true,layoutMap:{type:"cell-container",orientation:"horizontal",elements:[{type:"cell",flexValue:1,id:"js_"+BX.util.getRandomString()}]}})},getDoubledPriorityRow:function(){return new BX.Report.Dashboard.Row({id:"js_"+BX.util.getRandomString(),pseudo:true,layoutMap:{type:"cell-container",orientation:"horizontal",elements:[{type:"cell",flexValue:1,id:"js_"+BX.util.getRandomString()},{type:"cell",flexValue:1,id:"js_"+BX.util.getRandomString()}]}})},autoResize:function(){if(!this.dragElement.scaled){this.dragElement.style.transform="scale(0.5)";this.dragElement.style.transition="100ms";this.dragElement.style.zIndex="9999";this.dragElement.scaled=true;this.dragElement.style.transformOrigin=this.dragWidgetOffsetX+"px "+this.dragWidgetOffsetY+"px";this.dragElement.style.mstransformOrigin=this.dragWidgetOffsetX+"px "+this.dragWidgetOffsetY+"px";this.dragElement.style.webkittransformOrigin=this.dragWidgetOffsetX+"px "+this.dragWidgetOffsetY+"px"}},rotateDragWidget:function(t){if(!this.dragElement.rotated){if(jsDD.start_x>t){this.dragElement.classList.add("report-visualconstructor-dashboard-widget-rotated-right")}else{this.dragElement.classList.add("report-visualconstructor-dashboard-widget-rotated-left")}this.dragElement.rotated=true}},moveDragWidget:function(t,e){if(t<0||e<0){return}if(this.dragElement){this.dragElement.style.left=t-this.dragWidgetOffsetX+"px";this.dragElement.style.top=e-this.dragWidgetOffsetY+"px"}},onDragStop:function(){this.stopScroll();BX.remove(this.dragElement);this.dragElement=null;this.getCell().getContainer().style.height="";this.resetRectArea()},onDragFinish:function(t){if(t.dataset.type!=="cell"){this.getCell().setWidget(this)}},onDragEnd:function(){if(!this.dropped){this.getCell().setWidget(this);this.getCell().getRow().getBoard().removePseudoRows()}},getHeadContainer:function(){if(this.layout.headContainer){this.layout.headContainer.style.backgroundColor="";return this.layout.headContainer}this.layout.headContainer=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-widget-head-container","data-id":this.getId(),"data-weight":this.getWeight(),"data-type":"widget"}});return this.layout.headContainer},getHeadWrapper:function(){if(this.layout.headWrapper){return this.layout.headWrapper}this.layout.headWrapper=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-widget-head-wrapper"}});return this.layout.headWrapper},getTitleContainer:function(){if(this.layout.titleContainer){return this.layout.titleContainer}this.layout.titleContainer=BX.create("div",{props:{className:"report-visualconstructor-dashboard-widget-title-container"}});return this.layout.titleContainer},getControlsContainer:function(){if(this.layout.controlsContainer){return this.layout.controlsContainer}this.layout.controlsContainer=BX.create("div",{props:{className:"report-visualconstructor-dashboard-widget-controls-container"}});return this.layout.controlsContainer},getContentContainer:function(){if(this.layout.contentContainer){return this.layout.contentContainer}this.layout.contentContainer=BX.create("div",{props:{className:"report-visualconstructor-dashboard-widget-content-container"}});return this.layout.contentContainer},getContentWrapper:function(){if(this.layout.contentWrapper){return this.layout.contentWrapper}this.layout.contentWrapper=BX.create("div",{props:{className:"report-visualconstructor-dashboard-widget-content-wrapper"}});return this.layout.contentWrapper},setRowId:function(t){this.rowId=t},setRow:function(t){this.row=t;this.rowId=this.row.getId()},getRow:function(){return this.row},getCell:function(){return this.cell},setCell:function(t){this.cell=t;this.weight=this.cell.getId()},getId:function(){return this.id},getWeight:function(){return this.weight},getContent:function(){return this.runtimeContent},setContent:function(t){if(BX.type.isPlainObject(t)&&!(t instanceof BX.Report.Dashboard.Content)){var e=this.getContentClass(t.className);t.params.widget=this;this.runtimeContent=new e(t.params)}else if(t instanceof BX.Report.Dashboard.Content){this.runtimeContent.setWidget(this)}if(this.runtimeContent.errors.length!==0){var i={errors:this.runtimeContent.errors};this.runtimeContent=new BX.Report.Dashboard.Content.Error(i)}},getHeight:function(){if(this.getContent().getHeight()!=="auto"){return this.getContent().getHeight()+55}else{return 323}},getContentClass:function(t){var e=BX.Report.Dashboard.Utils.getClass(t);if(BX.type.isFunction(e)){return e}return BX.Report.Dashboard.Content.Empty},getBoard:function(){return this.board},setBoard:function(t){this.board=t},lazyLoad:function(){this.loaded=true;this.render();BX.onCustomEvent(this,"Dashboard.Board.Widget:onAfterRender")},render:function(){var t=this.getWidgetContainer();var e=this.getWidgetWrapper();var i=this.getContent();if(this.loaded){if(this.checkIsRendered()){this.clean()}if(this.isHeadEnabled){var r=this.getHeadContainer();var n=this.getHeadWrapper();var o=this.getControlsContainer();var s=this.getTitleContainer();s.innerHTML=this.config.title;n.appendChild(s);o.appendChild(this.getPropertiesOpenButton());n.appendChild(o);r.appendChild(n);e.appendChild(r)}this.applyColor();var a=this.getContentWrapper();var l=this.getContentContainer();l.appendChild(a);a.appendChild(i.render());e.appendChild(l);this.getLazyLoadPresetContainer().classList.add("report-visualconstructor-dashboard-widget-lazy-load-preset-disable");t.appendChild(e)}else{var d=this.getLazyLoadPresetContainer();t.appendChild(d)}this.setRenderStatus(true);return t},clean:function(){BX.cleanNode(this.getWidgetContainer());BX.cleanNode(this.getContentContainer());BX.cleanNode(this.getContentWrapper())},remove:function(){this.getCell().clear();this.getDeleteConfirmPopup().close();this.getRow().removeWidget(this)},destroy:function(){this.setRenderStatus(false);jsDD.unregisterObject(this.getWidgetContainer());BX.remove(this.getWidgetContainer());delete this.propertiesPopup},getPropertiesOpenButton:function(){if(this.layout.menuOpenButton){return this.layout.menuOpenButton}this.layout.menuOpenButton=BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-widget-properties-button"},events:{click:this.propertiesOpenButtonClickHandler.bind(this)}});return this.layout.menuOpenButton},propertiesOpenButtonClickHandler:function(t){var e=t.target||t.srcElement;this.openPopupMenu(e)},getPropertiesPopup:function(t){if(!this.propertiesPopup){var e="report-visualconstructor-drashboard-widget-popup"+this.getId();this.propertiesPopup=new BX.PopupWindow(e,t,{noAllPaddings:true,closeByEsc:true,autoHide:true,content:this.getActionsMenuItemsLayout()})}return this.propertiesPopup},openPopupMenu:function(t){this.getPropertiesPopup(t).show()},getActionsMenuItemsLayout:function(){for(var t in this.actionItems){this.actionItems[t].classList.add("report-visualconstructor-dashboard-widget-properties-popup-item")}return BX.create("div",{attrs:{className:"report-visualconstructor-dashboard-widget-properties-popup-wrapper"},children:this.actionItems})},openDeleteConfirmPopup:function(){this.getPropertiesPopup().close();this.removePopup=new BX.PopupWindow("report-visualconstructor-dashboard-widget-remove-popup-"+this.getId(),null,{closeIcon:{right:"20px",top:"10px"},titleBar:this.config.title,zIndex:0,offsetLeft:0,offsetTop:0,draggable:{restrict:false},overlay:{backgroundColor:"black",opacity:"80"},buttons:[new BX.PopupWindowButton({text:BX.message("DASHBOARD_WIDGET_REMOVE_ACCEPT_TITLE"),className:"popup-window-button-accept",events:{click:this.remove.bind(this)}}),new BX.PopupWindowButton({text:BX.message("DASHBOARD_WIDGET_REMOVE_CANCEL_TITLE"),className:"webform-button-link-cancel",events:{click:function(){this.popupWindow.close()}}})],content:BX.message("DASHBOARD_WIDGET_REMOVE_CONTENT")});this.removePopup.show()},getDeleteConfirmPopup:function(){return this.removePopup},checkIsRendered:function(){return this.isRendered},setRenderStatus:function(t){this.isRendered=t},getRectArea:function(){if(!this.rectArea){this.rectArea=BX.pos(this.getWidgetContainer());this.rectArea.middle=this.rectArea.left+this.rectArea.width/2}return this.rectArea},resetRectArea:function(){this.rectArea=null},autoScroll:function(t,e){var i=window.pageYOffset||document.documentElement.scrollTop;var r=document.documentElement.clientHeight;var n=e-i;if(n>=r-50){this.scrollDown(t,e)}else if(n<=50){this.scrollUp(t,e)}else{this.stopScroll()}},scrollUp:function(t,e){if(this.isScrollingUp){return}this.isScrollingUp=true;this.timer=setInterval(function(){var i=window.pageYOffset||document.documentElement.scrollTop;window.scrollTo(0,i-10);e-=10;this.moveDragWidget(t,e)}.bind(this),20)},scrollDown:function(t,e){if(this.isScrollingDown){return}this.isScrollingDown=true;this.timer=setInterval(function(){var i=window.pageYOffset||document.documentElement.scrollTop;window.scrollTo(0,i+10);e+=10;this.moveDragWidget(t,e)}.bind(this),20)},stopScroll:function(){this.isScrollingUp=false;this.isScrollingDown=false;clearInterval(this.timer)}}})(); //# sourceMappingURL=widget.map.js