UNPKG

@lidorsystems/integralui-web

Version:

IntegralUI Web - Advanced UI Components for Angular

15 lines (12 loc) 9.31 kB
/* filename: integralui.tab.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 s(){this.constructor=t}t.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}();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"),i0=require("@angular/core"),i1=require("../services/integralui.common.service"),i2=require("./integralui.core"),i3=require("@angular/common"),_c0=["content"],_c1=function(e,t,i,s,n,o){return{overflow:e,top:t,left:i,width:s,height:n,opacity:o}},_c2=["*"],IntegralUITab=function(e){__extends(t,e);function t(t,i,s){var n=e.call(this,i)||this;n.elemRef=t;n.commonService=i;n.baseService=s;n.parentCtrl=null;n.contentOverflow="auto";n.elemOrder=0;n.isContentHidden=!0;n.contentPos={top:0,left:0};n.elemHeight="0";n.elemWidth="0";n.leftPos=0;n.topPos=0;n.isSelected=!1;n.contentOpacity=1;n.elemBorderColor="gray";n.contentClass=[];n.allowDrag=!1;n.allowDrop=!0;n.animation=integralui_core_1.IntegralUIAnimationType.Fade;n.selectedChanged=new core_1.EventEmitter;return n}Object.defineProperty(t.prototype,"selected",{get:function(){return this.isSelected},set:function(e){if(this.isSelected!=e){if(e)this.state|=integralui_core_1.IntegralUIObjectState.selected;else this.state&=~integralui_core_1.IntegralUIObjectState.selected;this.isSelected=e;this.elemOrder=e?2:0;this.isContentHidden=!1===e?!0:!1}},enumerable:!0,configurable:!0});t.prototype.ngOnInit=function(){this.parentCtrl=this.baseService.getComponent();this.generalClassName="iui-tab";this.headerClassName=this.generalClassName+"-header";this.contentClassName=this.generalClassName+"-content";this.initStyle()};t.prototype.initStyle=function(){this.defaultStyle={general:{disabled:this.generalClassName+"-disabled",focused:this.generalClassName+"-focused",normal:this.generalClassName,hovered:this.generalClassName+"-hovered",selected:this.generalClassName+"-selected"},header:{disabled:this.headerClassName+"-disabled",focused:this.headerClassName+"-focused",normal:this.headerClassName,hovered:this.headerClassName+"-hovered",selected:this.headerClassName+"-selected"},content:{disabled:this.contentClassName+"-disabled",focused:this.contentClassName+"-focused",normal:this.contentClassName,hovered:this.contentClassName+"-hovered",selected:this.contentClassName+"-selected"}};this.updateStyle(this.controlStyle);this.updateControlClass();this.updateContentClass()};t.prototype.processStateChanged=function(){this.updateContentClass()};t.prototype.getSize=function(e){var t={width:0,height:0};if(e)t={width:e.offsetWidth,height:e.offsetHeight};return t};t.prototype.updateLayout=function(e,t,i){this.topPos=e.top;this.leftPos=e.left;var s={top:0,right:0,bottom:0,left:0};if(this.contentElem)s=this.commonService.getPadding(this.contentElem.nativeElement);this.elemWidth=t.width-(s.left+s.right)+"px";if("auto"==t.height)this.elemHeight="auto";else this.elemHeight=t.height-(s.top+s.bottom)+"px";this.isContentHidden=i};t.prototype.updateOpacity=function(e){this.contentOpacity=e};t.prototype.updatePos=function(e){this.topPos=void 0!==e.top?e.top:this.topPos;this.leftPos=void 0!==e.left?e.left:this.leftPos};t.prototype.updateVisibility=function(e){this.isContentHidden=e};t.prototype.updateContentOverflow=function(e){this.contentOverflow=e};t.prototype.getLayoutParams=function(){var e={size:{width:0,height:0},padding:{top:0,right:0,bottom:0,left:0}};if(this.elemRef){var t=this.elemRef.nativeElement.children[0];e.size=this.getSize(t);e.padding=this.commonService.getPadding(t)}return e};t.prototype.updateContentClass=function(){this.contentClass.length=0;this.contentClass.push(this.contentClassName);this.contentClass.push(this.options.currentStyle.content.normal);if(this.state&integralui_core_1.IntegralUIObjectState.disabled)this.contentClass.push(this.options.currentStyle.content.disabled);else if(this.state&integralui_core_1.IntegralUIObjectState.focused)this.contentClass.push(this.options.currentStyle.content.focused);else if(this.state&integralui_core_1.IntegralUIObjectState.selected)this.contentClass.push(this.options.currentStyle.content.selected);else if(this.state&integralui_core_1.IntegralUIObjectState.hovered)this.contentClass.push(this.options.currentStyle.content.hovered)};t.prototype.getContentClass=function(){return this.contentClass};t.prototype.getContentStyle=function(e){if(this.commonService.isString(e))return e;else if(e)return{disabled:this.commonService.isFieldAvailable(e.disabled,this.contentClassName+"-disabled"),focused:this.commonService.isFieldAvailable(e.focused,this.contentClassName+"-focused"),hovered:this.commonService.isFieldAvailable(e.hovered,this.contentClassName+"-hovered"),normal:this.commonService.isFieldAvailable(e.normal,this.contentClassName),selected:this.commonService.isFieldAvailable(e.selected,this.contentClassName+"-selected")};else return{disabled:this.defaultStyle.content.disabled,focused:this.defaultStyle.content.focused,hovered:this.defaultStyle.content.hovered,normal:this.defaultStyle.content.normal,selected:this.defaultStyle.content.selected}};t.prototype.getHeaderStyle=function(e){if(this.commonService.isString(e))return e;else if(e)return{disabled:this.commonService.isFieldAvailable(e.disabled,this.headerClassName+"-disabled"),focused:this.commonService.isFieldAvailable(e.focused,this.headerClassName+"-focused"),hovered:this.commonService.isFieldAvailable(e.hovered,this.headerClassName+"-hovered"),normal:this.commonService.isFieldAvailable(e.normal,this.headerClassName),selected:this.commonService.isFieldAvailable(e.selected,this.headerClassName+"-selected")};else return{disabled:this.defaultStyle.header.disabled,focused:this.defaultStyle.header.focused,hovered:this.defaultStyle.header.hovered,normal:this.defaultStyle.header.normal,selected:this.defaultStyle.header.selected}};t.prototype.updateStyle=function(e){if(e)this.options.currentStyle={general:this.getGeneralStyle(e.general),header:this.getHeaderStyle(e.header),content:this.getContentStyle(e.content)};else this.options.currentStyle={general:{disabled:this.defaultStyle.general.disabled,focused:this.defaultStyle.general.focused,hovered:this.defaultStyle.general.hovered,normal:this.defaultStyle.general.normal,selected:this.defaultStyle.general.selected},header:{disabled:this.defaultStyle.header.disabled,focused:this.defaultStyle.header.focused,hovered:this.defaultStyle.header.hovered,normal:this.defaultStyle.header.normal,selected:this.defaultStyle.header.selected},content:{disabled:this.defaultStyle.content.disabled,focused:this.defaultStyle.content.focused,hovered:this.defaultStyle.content.hovered,normal:this.defaultStyle.content.normal,selected:this.defaultStyle.content.selected}}};t.prototype.getCurrentTabStyle=function(){return this.options.currentStyle};t.ɵfac=function(e){return new(e||t)(i0.ɵɵdirectiveInject(i0.ElementRef),i0.ɵɵdirectiveInject(i1.IntegralUICommonService),i0.ɵɵdirectiveInject(i2.IntegralUIBaseService))};t.ɵcmp=i0.ɵɵdefineComponent({type:t,selectors:[["iui-tab"]],viewQuery:function(e,t){if(1&e)i0.ɵɵviewQuery(_c0,!0);if(2&e){var i;i0.ɵɵqueryRefresh(i=i0.ɵɵloadQuery())&&(t.contentElem=i.first)}},inputs:{controlStyle:"controlStyle",data:"data",enabled:"enabled",name:"name",state:"state",allowDrag:"allowDrag",allowDrop:"allowDrop",animation:"animation",icon:"icon",text:"text",selected:"selected"},outputs:{selectedChanged:"selectedChanged"},features:[i0.ɵɵInheritDefinitionFeature],ngContentSelectors:_c2,decls:4,vars:10,consts:[[3,"ngClass","ngStyle","hidden"],["content",""]],template:function(e,t){if(1&e){i0.ɵɵprojectionDef();i0.ɵɵelementStart(0,"div",0,1);i0.ɵɵelementStart(2,"div");i0.ɵɵprojection(3);i0.ɵɵelementEnd();i0.ɵɵelementEnd()}if(2&e)i0.ɵɵproperty("ngClass",t.getContentClass())("ngStyle",i0.ɵɵpureFunction6(3,_c1,t.contentOverflow,t.topPos+"px",t.leftPos+"px",t.elemWidth,t.elemHeight,t.contentOpacity))("hidden",t.isContentHidden&&2!==t.animation)},directives:[i3.NgClass,i3.NgStyle],encapsulation:2});return t}(integralui_core_1.IntegralUIBaseComponent);exports.IntegralUITab=IntegralUITab;