@lidorsystems/integralui-web
Version:
IntegralUI Web - Advanced UI Components for Angular
15 lines (12 loc) • 7.31 kB
JavaScript
/*
filename: integralui.progressbar.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 t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)if(e.hasOwnProperty(i))t[i]=e[i]})(e,i)};return function(e,i){t(e,i);function n(){this.constructor=e}e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();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"),forms_1=require("@angular/forms"),i0=require("@angular/core"),i1=require("../services/integralui.common.service"),i2=require("@angular/common");function IntegralUIProgressBar_div_2_Template(t,e){if(1&t)i0.ɵɵelement(0,"div",1);if(2&t){var i=i0.ɵɵnextContext();i0.ɵɵproperty("ngClass",i.getContentClass())("ngStyle",i.getProgressFadingStyle())}}var IntegralUIProgressBar=function(t){__extends(e,t);function e(e,i){var n=t.call(this,e,i)||this;n.elemRef=e;n.commonService=i;n.ctrlPadding={top:0,right:0,bottom:0,left:0};n.currentOrientation=integralui_core_1.IntegralUIOrientation.Horizontal;n.contentSize={width:0,height:0};n.fadingSize={width:0,height:0};n.orientationChanged=new core_1.EventEmitter;n.delayTimeout=null;return n}Object.defineProperty(e.prototype,"orientation",{get:function(){return this.currentOrientation},set:function(t){if(this.currentOrientation!=t){this.currentOrientation=t;this.updateLayout();this.orientationChanged.emit(null)}},enumerable:!0,configurable:!0});e.prototype.ngOnInit=function(){this.generalClassName="iui-progressbar";this.contentClassName=this.generalClassName+"-content";this.initStyle()};e.prototype.ngAfterViewInit=function(){this.updateLayout()};e.prototype.ngOnDestroy=function(){this.removeDelayTimeout()};e.prototype.ngAfterContentChecked=function(){if(1==this.autoUpdate){this.clientRect={width:this.elemRef.nativeElement.firstElementChild.clientWidth,height:this.elemRef.nativeElement.firstElementChild.clientHeight};if(this.clientRect.width!=this.prevClientRect.width){this.updateLayout();this.prevClientRect.width=this.clientRect.width}else if(this.clientRect.height!=this.prevClientRect.height){this.updateLayout();this.prevClientRect.height=this.clientRect.height}}};e.prototype.animateProgress=function(){var t=this,e=t.currentOrientation==integralui_core_1.IntegralUIOrientation.Horizontal?t.currentValue<100?Math.floor(t.clientRect.width*t.currentValue/100):t.clientRect.width:t.currentValue<100?Math.floor(t.clientRect.height*t.currentValue/100):t.clientRect.height;if(t.allowAnimation){var i=setInterval(function(){if(t.currentOrientation==integralui_core_1.IntegralUIOrientation.Horizontal)if(t.contentSize.width<e)t.contentSize.width+=3;else{t.contentSize.width=e;clearInterval(i)}else if(t.contentSize.height<e)t.contentSize.height+=3;else{t.contentSize.height=e;clearInterval(i)}},1);t.removeDelayTimeout();t.delayTimeout=setTimeout(function(){var i=setInterval(function(){if(t.currentOrientation==integralui_core_1.IntegralUIOrientation.Horizontal)if(t.fadingSize.width>e)t.fadingSize.width-=3;else{t.fadingSize.width=e;clearInterval(i)}else if(t.fadingSize.height>e)t.fadingSize.height-=3;else{t.fadingSize.height=e;clearInterval(i)}},1);clearTimeout(t.delayTimeout)},500)}else if(t.currentOrientation==integralui_core_1.IntegralUIOrientation.Horizontal)t.contentSize.width=e;else t.contentSize.height=e};e.prototype.removeDelayTimeout=function(){if(this.delayTimeout)clearTimeout(this.delayTimeout)};e.prototype.processValueChange=function(){this.updateLayout()};e.prototype.updateLayout=function(){var t=this,e=setTimeout(function(){t.ctrlPadding=t.commonService.getPadding(t.elemRef.nativeElement.firstElementChild);t.clientRect={width:t.elemRef.nativeElement.firstElementChild.clientWidth-(t.ctrlPadding.left+t.ctrlPadding.right),height:t.elemRef.nativeElement.firstElementChild.clientHeight-(t.ctrlPadding.top+t.ctrlPadding.bottom)};t.animateProgress();clearTimeout(e)},1)};e.prototype.getControlStyle=function(){var t={};if(this.ctrlSize.width>0)t.width=this.ctrlSize.width+"px";if(this.ctrlSize.height>0)t.height=this.ctrlSize.height+"px";return t};e.prototype.getProgressStyle=function(){var t={"z-index":2};if(this.currentOrientation==integralui_core_1.IntegralUIOrientation.Horizontal)t.width=this.contentSize.width+"px";else{t.position="absolute";t.bottom="-1px";t.height=this.contentSize.height+"px"}if(this.currentOrientation==integralui_core_1.IntegralUIOrientation.Horizontal);return t};e.prototype.getProgressFadingStyle=function(){var t={opacity:"0.25",position:"absolute","z-index":1};if(this.currentOrientation==integralui_core_1.IntegralUIOrientation.Horizontal){t.left=this.ctrlPadding.left+"px";t.top=this.ctrlPadding.top+"px";t.width=this.fadingSize.width+"px"}else{t.left=this.ctrlPadding.left+"px";t.bottom=this.ctrlPadding.bottom-1+"px";t.height=this.fadingSize.height+"px"}return t};e.ɵfac=function(t){return new(t||e)(i0.ɵɵdirectiveInject(i0.ElementRef),i0.ɵɵdirectiveInject(i1.IntegralUICommonService))};e.ɵcmp=i0.ɵɵdefineComponent({type:e,selectors:[["iui-progressbar"]],inputs:{autoUpdate:"autoUpdate",controlStyle:"controlStyle",data:"data",enabled:"enabled",name:"name",size:"size",state:"state",value:"value",orientation:"orientation"},outputs:{valueChanged:"valueChanged",orientationChanged:"orientationChanged"},features:[i0.ɵɵProvidersFeature([{provide:forms_1.NG_VALUE_ACCESSOR,useExisting:core_1.forwardRef(function(){return e}),multi:!0}]),i0.ɵɵInheritDefinitionFeature],decls:3,vars:5,consts:[["draggable","true",3,"ngClass","ngStyle","dragstart"],[3,"ngClass","ngStyle"],[3,"ngClass","ngStyle",4,"ngIf"]],template:function(t,e){if(1&t){i0.ɵɵelementStart(0,"div",0);i0.ɵɵlistener("dragstart",function(t){return e.preventDragStart(t)});i0.ɵɵelement(1,"div",1);i0.ɵɵtemplate(2,IntegralUIProgressBar_div_2_Template,1,2,"div",2);i0.ɵɵelementEnd()}if(2&t){i0.ɵɵproperty("ngClass",e.getControlClass())("ngStyle",e.getControlStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("ngClass",e.getContentClass())("ngStyle",e.getProgressStyle());i0.ɵɵadvance(1);i0.ɵɵproperty("ngIf",e.allowAnimation)}},directives:[i2.NgClass,i2.NgStyle,i2.NgIf],encapsulation:2});return e}(integralui_core_1.IntegralUIBaseValueComponent);exports.IntegralUIProgressBar=IntegralUIProgressBar;