UNPKG

@lidorsystems/integralui-web

Version:

IntegralUI Web - Advanced UI Components for Angular

15 lines (12 loc) 31.3 kB
/* filename: integralui.sidebar.js version : 20.2.0 Copyright © 2016-2020 Lidor Systems. All rights reserved. This file is part of the "IntegralUI Web" Library. The contents of this file are subject to the IntegralUI Web License, and may not be used except in compliance with the License. A copy of the License should have been installed in the product's root installation directory or it can be found at http://www.lidorsystems.com/products/web/studio/license-agreement.aspx. This SOFTWARE is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Any infringement will be prosecuted under applicable laws. */ "use strict";var __extends=this&&this.__extends||function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)if(t.hasOwnProperty(i))e[i]=t[i]})(t,i)};return function(t,i){e(t,i);function p(){this.constructor=t}t.prototype=null===i?Object.create(i):(p.prototype=i.prototype,new p)}}();Object.defineProperty(exports,"__esModule",{value:!0});var core_1=require("@angular/core"),integralui_core_1=require("./integralui.core"),integralui_common_service_1=require("../services/integralui.common.service"),integralui_data_service_1=require("../services/integralui.data.service"),i0=require("@angular/core"),i1=require("../services/integralui.common.service"),i2=require("@angular/common"),i3=require("./integralui.core");function IntegralUISideContentPopup_div_1_div_1_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",7);i0.ɵɵtext(1);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵtextInterpolate(i.title)}}var _c0=function(e){return{$implicit:e}};function IntegralUISideContentPopup_div_1_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",4);i0.ɵɵtemplate(1,IntegralUISideContentPopup_div_1_div_1_Template,2,1,"div",5);i0.ɵɵelementStart(2,"div",6);i0.ɵɵelement(3,"span",3);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i.getHeaderStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",!i.templateObj.headerTemplate&&i.title&&""!=i.title);i0.ɵɵadvance(2);i0.ɵɵproperty("iuiTemplateOutlet",i.templateObj.headerTemplate)("iuiTemplateOutletContext",i0.ɵɵpureFunction1(4,_c0,i.templateObj.data))}}var _c1=["header"],_c2=["headerButton"],_c3=["headerBlock"],_c4=["content"],_c5=function(e,t,i,p){return{top:e,width:t,height:i,opacity:p}};function IntegralUISideBar_div_1_Template(e,t){if(1&e)i0.ɵɵelement(0,"div",8);if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction4(1,_c5,i.headerOffsetHeight+"px",i.minCtrlSize.width+"px",i.maxCtrlSize.height+"px",i.barOpacity))}}function IntegralUISideBar_div_7_div_2_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",14);i0.ɵɵtext(1);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext(2);i0.ɵɵadvance(1);i0.ɵɵtextInterpolate(i.title)}}var _c6=function(e,t){return{marginLeft:e,width:t}};function IntegralUISideBar_div_7_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",9,10);i0.ɵɵtemplate(2,IntegralUISideBar_div_7_div_2_Template,2,1,"div",11);i0.ɵɵelementStart(3,"div",12);i0.ɵɵelement(4,"span",13);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i0.ɵɵpureFunction2(4,_c6,i.currentHeaderBlockPos+"px",i.maxCtrlSize.width-i.minCtrlSize.width-i.currentHeaderBlockPos+"px"));i0.ɵɵadvance(2);i0.ɵɵproperty("ngIf",0==i.headerData[0].length&&i.title&&""!=i.title);i0.ɵɵadvance(2);i0.ɵɵproperty("iuiTemplateOutlet",i.headerData[0])("iuiTemplateOutletContext",i0.ɵɵpureFunction1(7,_c0,i.data))}}function IntegralUISideBar_div_8_Template(e,t){if(1&e){i0.ɵɵelementStart(0,"div",15,16);i0.ɵɵelement(2,"span",13);i0.ɵɵelementEnd()}if(2&e){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngStyle",i.getContentStyle());i0.ɵɵadvance(2);i0.ɵɵproperty("iuiTemplateOutlet",i.contentData[0])("iuiTemplateOutletContext",i0.ɵɵpureFunction1(3,_c0,i.data))}}var IntegralUISideContentPopup=function(e){__extends(t,e);function t(t,i){var p=e.call(this,t,i)||this;p.elemRef=t;p.commonService=i;p.headerHeight=0;p.headerOffsetHeight=0;p.placement=integralui_core_1.IntegralUIPlacement.Left;p.closed=new core_1.EventEmitter;return p}t.prototype.ngOnInit=function(){this.generalClassName="iui-sidecontent-popup";this.initStyle()};t.prototype.ngAfterContentInit=function(){this.focus()};t.prototype.ngAfterViewInit=function(){};t.prototype.open=function(){this.isVisible=!0};t.prototype.close=function(){this.isVisible=!1;this.closed.emit(null)};t.prototype.processClose=function(){this.close()};t.prototype.getContentStyle=function(){var e={};switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:e.marginTop=this.size.height-this.maxSize.height+"px";e.width=this.maxSize.width+"px";e.height=this.maxSize.height+"px";break;case integralui_core_1.IntegralUIPlacement.Right:e.width=this.maxSize.width+"px";e.height=this.maxSize.height-this.headerOffsetHeight+"px";break;case integralui_core_1.IntegralUIPlacement.Bottom:e.width=this.maxSize.width+"px";e.height=this.maxSize.height+"px";break;default:e.borderLeft=0;e.marginLeft=this.size.width-this.maxSize.width+"px";e.width=this.maxSize.width+"px";e.height=this.maxSize.height-this.headerOffsetHeight+"px"}return e};t.prototype.getHeaderStyle=function(){return{borderTop:0,borderRight:0,borderLeft:0,height:this.headerHeight+"px"}};t.ɵfac=function(e){return new(e||t)(i0.ɵɵdirectiveInject(i0.ElementRef),i0.ɵɵdirectiveInject(i1.IntegralUICommonService))};t.ɵcmp=i0.ɵɵdefineComponent({type:t,selectors:[["iui-side-content-popup"]],inputs:{headerHeight:"headerHeight",headerOffsetHeight:"headerOffsetHeight",placement:"placement",title:"title"},outputs:{closed:"closed"},features:[i0.ɵɵInheritDefinitionFeature],decls:4,vars:8,consts:[["tabindex","999",3,"ngClass","ngStyle"],["class","iui-sidebar-header","style","padding-left:0;",3,"ngStyle",4,"ngIf"],[1,"iui-sidebar-content",3,"ngStyle"],[3,"iuiTemplateOutlet","iuiTemplateOutletContext"],[1,"iui-sidebar-header",2,"padding-left","0",3,"ngStyle"],["class","iui-sidebar-header-title",4,"ngIf"],[1,"iui-sidebar-header-content"],[1,"iui-sidebar-header-title"]],template:function(e,t){if(1&e){i0.ɵɵelementStart(0,"div",0);i0.ɵɵtemplate(1,IntegralUISideContentPopup_div_1_Template,4,6,"div",1);i0.ɵɵelementStart(2,"div",2);i0.ɵɵelement(3,"span",3);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e){i0.ɵɵproperty("ngClass",t.getControlClass())("ngStyle",t.getControlStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.placement%2==1);i0.ɵɵadvance(1);i0.ɵɵproperty("ngStyle",t.getContentStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("iuiTemplateOutlet",t.templateObj.contentTemplate)("iuiTemplateOutletContext",i0.ɵɵpureFunction1(6,_c0,t.templateObj.data))}},directives:[i2.NgClass,i2.NgStyle,i2.NgIf,i3.IntegralUITemplateOutlet],encapsulation:2});return t}(integralui_core_1.IntegralUIPopup);exports.IntegralUISideContentPopup=IntegralUISideContentPopup;var IntegralUISideBar=function(e){__extends(t,e);function t(t,i,p,o){var n=e.call(this,i)||this;n.elemRef=t;n.commonService=i;n.cmpResolver=p;n.baseService=o;n.closeTimer=null;n.openTimer=null;n.contentData=[];n.headerData=[];n.isTouchProcessed=!1;n.barOpacity=1;n.barSize={width:0,height:0};n.currentHeaderBlockPos=0;n.currentPlacement=integralui_core_1.IntegralUIPlacement.Left;n.contentSize={width:0,height:0};n.currentSize={width:0,height:0};n.headerBlockSize={width:0,height:0};n.headerHeight=0;n.headerOffsetHeight=0;n.maxCtrlSize={width:0,height:0};n.minCtrlSize={width:0,height:0};n.expandValue=!1;n.isPopupVisible=!1;n.popupValue=!1;n.templateList=[];n.popupRef=null;n.popupCmp=null;n.tRef=null;n.animationSpeed=integralui_core_1.IntegralUISpeedMode.Normal;n.collapsed=new core_1.EventEmitter;n.collapsing=new core_1.EventEmitter;n.expanded=new core_1.EventEmitter;n.expanding=new core_1.EventEmitter;return n}t.prototype.ngOnInit=function(){this.baseService.setComponent(this);this.generalClassName="iui-sidebar";this.initStyle()};t.prototype.ngAfterViewInit=function(){var e=this,t=setTimeout(function(){var i=e.cmpResolver.resolveComponentFactory(integralui_core_1.IntegralUITComponent);if(i&&e.headerRef)e.tRef=e.headerRef.createComponent(i);clearTimeout(t)},100)};t.prototype.ngAfterContentInit=function(){var e=this;e.updateTemplate();var t=setTimeout(function(){e.addPopup();clearTimeout(t)},1);e.updateLayout()};t.prototype.updateTemplate=function(){this.contentData.length=0;this.headerData.length=0;if(this.templates){this.templateList=this.templates.toArray();for(var e=0;e<this.templateList.length;e++)if(this.templateList[e].settings)switch(this.templateList[e].settings.type){case"header":this.headerData.push(this.templateList[e].getTemplate());break;case"content":this.contentData.push(this.templateList[e].getTemplate())}}};t.prototype.removeCloseTimer=function(){if(this.closeTimer)clearInterval(this.closeTimer)};t.prototype.removeOpenTimer=function(){if(this.openTimer)clearInterval(this.openTimer)};t.prototype.ngOnDestroy=function(){this.removePopup();this.removeCloseTimer();this.removeOpenTimer();if(this.tRef)this.tRef.destroy()};Object.defineProperty(t.prototype,"isExpanded",{get:function(){return this.expandValue},set:function(e){if(this.expandValue!=e){this.expandValue=e;this.toggle()}},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"placement",{get:function(){return this.currentPlacement},set:function(e){if(void 0!=e&&this.currentPlacement!=e){this.currentPlacement=e;this.updateLayout()}},enumerable:!0,configurable:!0});Object.defineProperty(t.prototype,"popup",{get:function(){return this.popupValue},set:function(e){if(this.popupValue!=e){this.popupValue=e;this.isExpanded=!1}},enumerable:!0,configurable:!0});t.prototype.addPopup=function(){var e=this;if(e.appRef&&e.contentData.length>0){e.removePopup();var t=e.cmpResolver.resolveComponentFactory(IntegralUISideContentPopup);if(t){e.popupRef=e.appRef.createComponent(t);if(e.popupRef.instance)e.popupCmp=e.popupRef.instance;e.hidePopup();if(e.popupCmp){e.popupCmp.templateObj={data:{},contentTemplate:e.contentData[0],headerTemplate:e.headerData[0]};e.popupCmp.closed.subscribe(function(t){e.hidePopup()})}}}};t.prototype.removePopup=function(){if(this.popupCmp)if(this.popupCmp.closed)this.popupCmp.closed.unsubscribe();if(this.popupRef)this.popupRef.destroy();this.popupCmp=null};t.prototype.hidePopup=function(){if(this.popupCmp)this.closePopup()};t.prototype.showPopup=function(){if(this.popupCmp){var e=this.commonService.getShiftPos(),t=this.commonService.getPageRect(this.elemRef.nativeElement.firstElementChild);this.popupCmp.allowAnimation=this.allowAnimation;this.popupCmp.display="block";this.popupCmp.title=this.title;this.popupCmp.headerHeight=this.headerHeight;this.popupCmp.headerOffsetHeight=this.headerOffsetHeight;this.popupCmp.placement=this.placement;switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:this.popupCmp.position={x:t.left+e.x,y:t.bottom+e.y-1};this.popupCmp.size={width:this.barSize.width,height:0};this.popupCmp.maxSize={width:this.barSize.width,height:this.maxCtrlSize.height-this.minCtrlSize.height};break;case integralui_core_1.IntegralUIPlacement.Right:this.popupCmp.position={x:t.left+e.x,y:t.top+e.y};this.popupCmp.size={width:0,height:this.barSize.height};this.popupCmp.maxSize={width:this.maxCtrlSize.width-this.minCtrlSize.width,height:this.barSize.height};break;case integralui_core_1.IntegralUIPlacement.Bottom:this.popupCmp.position={x:t.left+e.x,y:t.top+e.y-1};this.popupCmp.size={width:this.barSize.width,height:0};this.popupCmp.maxSize={width:this.barSize.width,height:this.maxCtrlSize.height-this.minCtrlSize.height};break;default:this.popupCmp.position={x:t.right+e.x-1,y:t.top+e.y};this.popupCmp.size={width:0,height:this.barSize.height};this.popupCmp.maxSize={width:this.maxCtrlSize.width-this.minCtrlSize.width,height:this.barSize.height}}this.popupCmp.open();this.openPopup();this.isPopupVisible=!0}};t.prototype.headerMouseDown=function(e){if(!this.isTouchProcessed)this.toggleButtonClicked();e.stopPropagation()};t.prototype.headerTouchStart=function(e){var t=this;t.isTouchProcessed=!0;t.toggleButtonClicked();setTimeout(function(){t.isTouchProcessed=!1},100);e.stopPropagation()};t.prototype.toggleButtonClicked=function(){if(this.popup||this.placement==integralui_core_1.IntegralUIPlacement.Right||this.placement==integralui_core_1.IntegralUIPlacement.Bottom){if(this.popupCmp)this.isPopupVisible?this.hidePopup():this.showPopup()}else this.isExpanded=!this.isExpanded};t.prototype.getCtrlSpace=function(e){var t=this.commonService.getPadding(this.elemRef.nativeElement),i=this.commonService.getBorderWidth(this.elemRef.nativeElement);return e?t.top+t.bottom+i.top+i.bottom:t.left+t.right+i.left+i.right};t.prototype.getMaxSize=function(){return{width:this.maxCtrlSize.width+this.getCtrlSpace(),height:this.maxCtrlSize.height+this.getCtrlSpace(!0)}};t.prototype.getMinSize=function(){return{width:this.minCtrlSize.width+this.getCtrlSpace(),height:this.minCtrlSize.height+this.getCtrlSpace(!0)}};t.prototype.updateLayout=function(){var e=this,t=setTimeout(function(){e.clientRect={width:e.size.width>0?e.size.width:e.elemRef.nativeElement.firstElementChild.clientWidth,height:e.size.height>0?e.size.height:e.elemRef.nativeElement.firstElementChild.clientHeight};var i=e.headerButtonElem?{width:e.headerButtonElem.nativeElement.offsetHeight,height:e.headerButtonElem.nativeElement.offsetHeight}:{width:0,height:0};e.headerBlockSize={width:e.headerBlockElem?e.headerBlockElem.nativeElement.offsetWidth:0,height:e.headerBlockElem?e.headerBlockElem.nativeElement.offsetHeight:0};var p=e.commonService.getPadding(e.headerElem.nativeElement),o=e.commonService.getBorderWidth(e.headerElem.nativeElement);e.headerHeight=Math.max(i.height,e.headerBlockSize.height);e.headerOffsetHeight=e.headerHeight+p.top+p.bottom+2;switch(e.currentPlacement){case integralui_core_1.IntegralUIPlacement.Top:e.barSize={width:e.clientRect.width,height:i.height+p.top+p.bottom+o.top+o.bottom};e.currentSize={width:e.clientRect.width,height:e.barSize.height};e.minCtrlSize={width:e.barSize.width,height:e.barSize.height};break;case integralui_core_1.IntegralUIPlacement.Right:e.barSize={width:i.width+p.left+p.right,height:e.clientRect.height};e.currentSize={width:e.barSize.width,height:e.clientRect.height-e.headerOffsetHeight};e.minCtrlSize={width:e.barSize.width,height:e.barSize.height};break;case integralui_core_1.IntegralUIPlacement.Bottom:e.barSize={width:e.clientRect.width,height:i.height+p.top+p.bottom+o.top+o.bottom};e.currentSize={width:e.clientRect.width,height:e.barSize.height};e.minCtrlSize={width:e.barSize.width,height:e.barSize.height};break;default:e.barSize={width:i.width+p.left+p.right,height:e.clientRect.height};e.currentSize={width:!e.isExpanded?e.barSize.width:e.clientRect.width,height:e.clientRect.height-e.headerOffsetHeight};e.minCtrlSize={width:e.barSize.width,height:e.barSize.height}}e.maxCtrlSize={width:e.clientRect.width,height:e.clientRect.height};e.currentHeaderBlockPos=p.left+p.right;clearTimeout(t)},1)};t.prototype.getAnimationFactor=function(e,t){var i=e;switch(this.animationSpeed){case integralui_core_1.IntegralUISpeedMode.VerySlow:i=t?e/4:e/2;break;case integralui_core_1.IntegralUISpeedMode.Slow:i=t?e/8:e/4;break;case integralui_core_1.IntegralUISpeedMode.Fast:i=t?e/20:e/15;break;case integralui_core_1.IntegralUISpeedMode.VeryFast:i=t?e/30:e/25;break;default:i=t?e/15:e/10}return i};t.prototype.close=function(){this.expandValue=!1;this.popup?this.closePopup():this.closeNormal()};t.prototype.closeNormal=function(){this.removeCloseTimer();this.removeOpenTimer();switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:this.closeFromTop();break;default:this.closeFromLeft()}};t.prototype.closeFromLeft=function(){var e=this;if(e.allowAnimation){var t=e.getAnimationFactor(e.maxCtrlSize.width,!0),i=e.size.width/t;e.barOpacity=0;e.closeTimer=setInterval(function(){if(e.currentSize.width>e.minCtrlSize.width){e.currentSize.width-=i;e.barOpacity=e.currentSize.width/e.maxCtrlSize.width;e.collapsing.emit({size:e.currentSize})}else{e.currentSize.width=e.minCtrlSize.width;e.barOpacity=1;e.collapsed.emit({size:e.currentSize});e.removeCloseTimer()}},5)}else{e.currentSize.width=e.minCtrlSize.width;e.barOpacity=1;e.collapsed.emit({size:e.currentSize})}};t.prototype.closeFromTop=function(){var e=this;if(e.allowAnimation){var t=e.getAnimationFactor(e.maxCtrlSize.height,!0),i=e.size.height/t;e.barOpacity=0;e.closeTimer=setInterval(function(){if(e.currentSize.height>e.minCtrlSize.height){e.currentSize.height-=i;e.barOpacity=e.currentSize.height/e.maxCtrlSize.height;e.collapsing.emit({size:e.currentSize})}else{e.currentSize.height=e.minCtrlSize.height;e.barOpacity=1;e.collapsed.emit({size:e.currentSize});e.removeCloseTimer()}},5)}else{e.currentSize.height=e.minCtrlSize.height;e.barOpacity=1;e.collapsed.emit({size:e.currentSize})}};t.prototype.closePopup=function(){this.removeCloseTimer();this.removeOpenTimer();switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:this.closePopupFromTop();break;case integralui_core_1.IntegralUIPlacement.Right:this.closePopupFromRight();break;case integralui_core_1.IntegralUIPlacement.Bottom:this.closePopupFromBottom();break;default:this.closePopupFromLeft()}};t.prototype.closePopupFromBottom=function(){var e=this,t=e.popupCmp.position.y;if(e.allowAnimation){var i=e.getAnimationFactor(e.popupCmp.maxSize.height,!0),p=e.popupCmp.maxSize.height/i;e.closeTimer=setInterval(function(){if(e.popupCmp.size.height>0){e.popupCmp.position={x:e.popupCmp.position.x,y:e.popupCmp.position.y+p};e.popupCmp.size={width:e.popupCmp.size.width,height:e.popupCmp.size.height-p};e.collapsing.emit({size:e.popupCmp.size})}else{e.popupCmp.position={x:e.popupCmp.position.x,y:t};e.popupCmp.size={width:e.popupCmp.size.width,height:0};e.popupCmp.display="none";e.isPopupVisible=!1;e.collapsed.emit({size:e.popupCmp.size});e.removeCloseTimer()}},5)}else{e.popupCmp.position={x:e.popupCmp.position.x,y:t};e.popupCmp.size={width:e.popupCmp.size.width,height:0};e.popupCmp.display="none";e.isPopupVisible=!1;e.collapsed.emit({size:e.popupCmp.size})}};t.prototype.closePopupFromLeft=function(){var e=this;if(e.allowAnimation){var t=e.getAnimationFactor(e.popupCmp.maxSize.width,!0),i=e.popupCmp.maxSize.width/t;e.closeTimer=setInterval(function(){if(e.popupCmp.size.width>0){e.popupCmp.size={width:e.popupCmp.size.width-i,height:e.popupCmp.size.height};e.collapsing.emit({size:e.popupCmp.size})}else{e.popupCmp.size={width:0,height:e.popupCmp.size.height};e.popupCmp.display="none";e.isPopupVisible=!1;e.collapsed.emit({size:e.popupCmp.size});e.removeCloseTimer()}},5)}else{e.popupCmp.size={width:0,height:e.popupCmp.size.height};e.popupCmp.display="none";e.isPopupVisible=!1;e.collapsed.emit({size:e.popupCmp.size})}};t.prototype.closePopupFromTop=function(){var e=this;if(e.allowAnimation){var t=e.getAnimationFactor(e.popupCmp.maxSize.height,!0),i=e.popupCmp.maxSize.height/t;e.closeTimer=setInterval(function(){if(e.popupCmp.size.height>0){e.popupCmp.size={width:e.popupCmp.size.width,height:e.popupCmp.size.height-i};e.collapsing.emit({size:e.popupCmp.size})}else{e.popupCmp.size={width:e.popupCmp.size.width,height:0};e.popupCmp.display="none";e.isPopupVisible=!1;e.collapsed.emit({size:e.popupCmp.size});e.removeCloseTimer()}},5)}else{e.popupCmp.size={width:e.popupCmp.size.width,height:0};e.popupCmp.display="none";e.isPopupVisible=!1;e.collapsed.emit({size:e.popupCmp.size})}};t.prototype.closePopupFromRight=function(){var e=this,t=e.popupCmp.position.x;if(e.allowAnimation){var i=e.getAnimationFactor(e.popupCmp.maxSize.width,!0),p=e.popupCmp.maxSize.width/i;e.closeTimer=setInterval(function(){if(e.popupCmp.size.width>0){e.popupCmp.position={x:e.popupCmp.position.x+p,y:e.popupCmp.position.y};e.popupCmp.size={width:e.popupCmp.size.width-p,height:e.popupCmp.size.height};e.collapsing.emit({size:e.popupCmp.size})}else{e.popupCmp.position={x:t,y:e.popupCmp.position.y};e.popupCmp.size={width:0,height:e.popupCmp.size.height};e.popupCmp.display="none";e.isPopupVisible=!1;e.collapsed.emit({size:e.popupCmp.size});e.removeCloseTimer()}},5)}else{e.popupCmp.position={x:t,y:e.popupCmp.position.y};e.popupCmp.size={width:0,height:e.popupCmp.size.height};e.popupCmp.display="none";e.isPopupVisible=!1;e.collapsed.emit({size:e.popupCmp.size})}};t.prototype.open=function(){this.expandValue=!0;this.popup?this.openPopup():this.openNormal()};t.prototype.openNormal=function(){this.removeCloseTimer();this.removeOpenTimer();switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:this.openFromTop();break;case integralui_core_1.IntegralUIPlacement.Left:this.openFromLeft()}};t.prototype.openFromLeft=function(){var e=this;if(e.allowAnimation){var t=e.getAnimationFactor(e.maxCtrlSize.width),i=e.size.width/t;e.barOpacity=1;e.openTimer=setInterval(function(){if(e.currentSize.width<e.maxCtrlSize.width){e.currentSize.width+=i;e.barOpacity=1-e.currentSize.width/e.maxCtrlSize.width;e.expanding.emit({size:e.currentSize})}else{e.currentSize.width=e.maxCtrlSize.width;e.barOpacity=0;e.expanded.emit({size:e.currentSize});e.removeOpenTimer()}},5)}else{e.currentSize.width=e.maxCtrlSize.width;e.barOpacity=0;e.expanded.emit({size:e.currentSize})}};t.prototype.openFromTop=function(){var e=this;if(e.allowAnimation){var t=e.getAnimationFactor(e.maxCtrlSize.height),i=e.size.height/t;e.barOpacity=1;e.openTimer=setInterval(function(){if(e.currentSize.height<e.maxCtrlSize.height){e.currentSize.height+=i;e.barOpacity=1-e.currentSize.height/e.maxCtrlSize.height}else{e.currentSize.height=e.maxCtrlSize.height;e.barOpacity=0;e.expanded.emit({size:e.currentSize});e.removeOpenTimer()}},5)}else{e.currentSize.height=e.maxCtrlSize.height;e.barOpacity=0;e.expanded.emit({size:e.currentSize})}};t.prototype.openPopup=function(){this.removeCloseTimer();this.removeOpenTimer();switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:this.openPopupFromTop();break;case integralui_core_1.IntegralUIPlacement.Right:this.openPopupFromRight();break;case integralui_core_1.IntegralUIPlacement.Bottom:this.openPopupFromBottom();break;default:this.openPopupFromLeft()}};t.prototype.openPopupFromBottom=function(){var e=this,t=e.popupCmp.position.y;if(e.allowAnimation){var i=e.getAnimationFactor(e.popupCmp.maxSize.height),p=e.popupCmp.maxSize.height/i;e.openTimer=setInterval(function(){if(e.popupCmp.size.height<e.popupCmp.maxSize.height){e.popupCmp.position={x:e.popupCmp.position.x,y:e.popupCmp.position.y-p};e.popupCmp.size={width:e.popupCmp.size.width,height:e.popupCmp.size.height+p};e.expanding.emit({size:e.popupCmp.size})}else{e.popupCmp.position={x:e.popupCmp.position.x,y:t-e.popupCmp.maxSize.height};e.popupCmp.size={width:e.popupCmp.size.width,height:e.popupCmp.maxSize.height};e.expanded.emit({size:e.popupCmp.size});e.removeOpenTimer()}},5)}else{e.popupCmp.position={x:e.popupCmp.position.x,y:t-e.popupCmp.maxSize.height};e.popupCmp.size={width:e.popupCmp.size.width,height:e.popupCmp.maxSize.height};e.expanded.emit({size:e.popupCmp.size})}};t.prototype.openPopupFromLeft=function(){var e=this;if(e.allowAnimation){var t=e.getAnimationFactor(e.popupCmp.maxSize.width),i=e.popupCmp.maxSize.width/t;e.openTimer=setInterval(function(){if(e.popupCmp.size.width<e.popupCmp.maxSize.width){e.popupCmp.size={width:e.popupCmp.size.width+i,height:e.popupCmp.size.height};e.expanding.emit({size:e.popupCmp.size})}else{e.popupCmp.size={width:e.popupCmp.maxSize.width,height:e.popupCmp.size.height};e.expanded.emit({size:e.popupCmp.size});e.removeOpenTimer()}},5)}else{e.popupCmp.size={width:e.popupCmp.maxSize.width,height:e.popupCmp.size.height};e.expanded.emit({size:e.popupCmp.size})}};t.prototype.openPopupFromTop=function(){var e=this;if(e.allowAnimation){var t=e.getAnimationFactor(e.popupCmp.maxSize.height),i=e.popupCmp.maxSize.height/t;e.openTimer=setInterval(function(){if(e.popupCmp.size.height<e.popupCmp.maxSize.height){e.popupCmp.size={width:e.popupCmp.size.width,height:e.popupCmp.size.height+i};e.expanding.emit({size:e.popupCmp.size})}else{e.popupCmp.size={width:e.popupCmp.size.width,height:e.popupCmp.maxSize.height};e.expanded.emit({size:e.popupCmp.size});e.removeOpenTimer()}},5)}else{e.popupCmp.size={width:e.popupCmp.size.width,height:e.popupCmp.maxSize.height};e.expanded.emit({size:e.popupCmp.size})}};t.prototype.openPopupFromRight=function(){var e=this,t=e.popupCmp.position.x;if(e.allowAnimation){var i=e.getAnimationFactor(e.popupCmp.maxSize.width),p=e.popupCmp.maxSize.width/i;e.openTimer=setInterval(function(){if(e.popupCmp.size.width<e.popupCmp.maxSize.width){e.popupCmp.position={x:e.popupCmp.position.x-p,y:e.popupCmp.position.y};e.popupCmp.size={width:e.popupCmp.size.width+p,height:e.popupCmp.size.height};e.expanding.emit({size:e.popupCmp.size})}else{e.popupCmp.position={x:t-e.popupCmp.maxSize.width,y:e.popupCmp.position.y};e.popupCmp.size={width:e.popupCmp.maxSize.width,height:e.popupCmp.size.height};e.expanded.emit({size:e.popupCmp.size});e.removeOpenTimer()}},5)}else{e.popupCmp.position={x:t-e.popupCmp.maxSize.width,y:e.popupCmp.position.y};e.popupCmp.size={width:e.popupCmp.maxSize.width,height:e.popupCmp.size.height};e.expanded.emit({size:e.popupCmp.size})}};t.prototype.toggle=function(){if(this.isExpanded)this.open();else this.close()};t.prototype.getControlStyle=function(){var e={};switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:case integralui_core_1.IntegralUIPlacement.Bottom:if(this.ctrlSize.width>0)e.width=this.ctrlSize.width+"px";e.height=this.currentSize.height+"px";break;default:e.width=this.currentSize.width+"px";if(this.ctrlSize.height>0)e.height=this.ctrlSize.height+"px"}return e};t.prototype.getContentStyle=function(){var e={};switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:e.marginTop=this.currentSize.height-this.maxCtrlSize.height+"px";e.height=this.clientRect.height-this.headerOffsetHeight+"px";break;case integralui_core_1.IntegralUIPlacement.Left:e.marginLeft=this.currentSize.width-this.maxCtrlSize.width+"px";e.height=this.clientRect.height-this.headerOffsetHeight+"px"}return e};t.prototype.getHeaderStyle=function(){var e={};switch(this.placement){case integralui_core_1.IntegralUIPlacement.Top:e.borderTop=0;e.borderRight=0;e.borderLeft=0;if(!this.isExpanded)e.borderBottom=0;break;case integralui_core_1.IntegralUIPlacement.Left:e.borderTop=0;e.borderRight=0;e.borderLeft=0}return e};t.prototype.updateControlClass=function(){this.ctrlClass.length=0;if(this.placement===integralui_core_1.IntegralUIPlacement.Left||this.placement===integralui_core_1.IntegralUIPlacement.Right)this.ctrlClass.push(this.generalClassName+"-horizontal");else this.ctrlClass.push(this.generalClassName+"-vertical");this.ctrlClass.push(this.generalClassName);if(this.options.currentStyle&&this.options.currentStyle.general){this.ctrlClass.push(this.options.currentStyle.general.normal);if(this.state&integralui_core_1.IntegralUIObjectState.disabled)this.ctrlClass.push(this.options.currentStyle.general.disabled);else if(this.state&integralui_core_1.IntegralUIObjectState.focused)this.ctrlClass.push(this.options.currentStyle.general.focused);else if(this.state&integralui_core_1.IntegralUIObjectState.selected)this.ctrlClass.push(this.options.currentStyle.general.selected);else if(this.state&integralui_core_1.IntegralUIObjectState.hovered)this.ctrlClass.push(this.options.currentStyle.general.hovered);if(this.allowAnimation)if(this.state&integralui_core_1.IntegralUIObjectState.hovered)this.ctrlClass.push(this.defaultStyle.general.normal+"-enter");else this.ctrlClass.push(this.defaultStyle.general.normal+"-leave")}};t.ɵfac=function(e){return new(e||t)(i0.ɵɵdirectiveInject(i0.ElementRef),i0.ɵɵdirectiveInject(i1.IntegralUICommonService),i0.ɵɵdirectiveInject(i0.ComponentFactoryResolver),i0.ɵɵdirectiveInject(i3.IntegralUIBaseService))};t.ɵcmp=i0.ɵɵdefineComponent({type:t,selectors:[["iui-sidebar"]],contentQueries:function(e,t,i){if(1&e)i0.ɵɵcontentQuery(i,integralui_core_1.IntegralUITemplate,!0);if(2&e){var p;i0.ɵɵqueryRefresh(p=i0.ɵɵloadQuery())&&(t.templates=p)}},viewQuery:function(e,t){if(1&e){i0.ɵɵviewQuery(_c1,!0,core_1.ViewContainerRef);i0.ɵɵviewQuery(_c1,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c2,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c3,!0,core_1.ElementRef);i0.ɵɵviewQuery(_c4,!0,core_1.ElementRef)}if(2&e){var i;i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.headerRef=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.headerElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.headerButtonElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.headerBlockElem=i.first);i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.contentElem=i.first)}},inputs:{controlStyle:"controlStyle",data:"data",enabled:"enabled",name:"name",size:"size",state:"state",animationSpeed:"animationSpeed",appRef:"appRef",isExpanded:"isExpanded",placement:"placement",popup:"popup",title:"title"},outputs:{collapsed:"collapsed",collapsing:"collapsing",expanded:"expanded",expanding:"expanding"},features:[i0.ɵɵProvidersFeature([integralui_core_1.IntegralUIBaseService,integralui_data_service_1.IntegralUIDataService]),i0.ɵɵInheritDefinitionFeature],decls:9,vars:6,consts:[[3,"ngClass","ngStyle"],["class","iui-sidebar-line",3,"ngStyle",4,"ngIf"],[1,"iui-sidebar-header",3,"ngStyle"],["header",""],[1,"iui-sidebar-header-button",3,"mousedown","touchstart"],["headerButton",""],["class","iui-sidebar-header-block",3,"ngStyle",4,"ngIf"],["class","iui-sidebar-content",3,"ngStyle",4,"ngIf"],[1,"iui-sidebar-line",3,"ngStyle"],[1,"iui-sidebar-header-block",3,"ngStyle"],["headerBlock",""],["class","iui-sidebar-header-title",4,"ngIf"],[1,"iui-sidebar-header-content"],[3,"iuiTemplateOutlet","iuiTemplateOutletContext"],[1,"iui-sidebar-header-title"],[1,"iui-sidebar-content",3,"ngStyle"],["content",""]],template:function(e,t){if(1&e){i0.ɵɵelementStart(0,"div",0);i0.ɵɵtemplate(1,IntegralUISideBar_div_1_Template,1,6,"div",1);i0.ɵɵelementStart(2,"div",2,3);i0.ɵɵelementStart(4,"div",4,5);i0.ɵɵlistener("mousedown",function(e){return t.headerMouseDown(e)})("touchstart",function(e){return t.headerTouchStart(e)});i0.ɵɵelement(6,"span");i0.ɵɵelementEnd();i0.ɵɵtemplate(7,IntegralUISideBar_div_7_Template,5,9,"div",6);i0.ɵɵelementEnd();i0.ɵɵtemplate(8,IntegralUISideBar_div_8_Template,3,5,"div",7);i0.ɵɵelementEnd()}if(2&e){i0.ɵɵproperty("ngClass",t.getControlClass())("ngStyle",t.getControlStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",t.placement%2==1);i0.ɵɵadvance(1);i0.ɵɵproperty("ngStyle",t.getHeaderStyle());i0.ɵɵadvance(5);i0.ɵɵproperty("ngIf",!t.popup||t.placement%2==0);i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",!t.popup&&(0==t.placement||3==t.placement))}},directives:[i2.NgClass,i2.NgStyle,i2.NgIf,i3.IntegralUITemplateOutlet],encapsulation:2});return t}(integralui_core_1.IntegralUIBaseComponent);exports.IntegralUISideBar=IntegralUISideBar;