@logo-software/timer
Version:
Timer helps developer to set a specific time for their web apps and doSomething after completed.
32 lines • 20.9 kB
JavaScript
!function(o,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("rxjs"),require("@angular/common"),require("@logo-software/progress-bar")):"function"==typeof define&&define.amd?define("@logo-software/timer",["exports","@angular/core","rxjs","@angular/common","@logo-software/progress-bar"],r):r(((o="undefined"!=typeof globalThis?globalThis:o||self)["logo-software"]=o["logo-software"]||{},o["logo-software"].timer={}),o.ng.core,o.rxjs,o.ng.common,o.progressBar)}(this,(function(o,r,t,e,a){"use strict";function n(o){if(o&&o.__esModule)return o;var r=Object.create(null);return o&&Object.keys(o).forEach((function(t){if("default"!==t){var e=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(r,t,e.get?e:{enumerable:!0,get:function(){return o[t]}})}})),r.default=o,Object.freeze(r)}var i=n(r),l=function(){function o(){}return o.prototype.transform=function(o,r){var t=Math.floor(o/1e3),e=Math.floor(t/60),a=Math.floor(e/60),n=Math.floor(a/24),i=Math.floor(a%24),l=Math.floor(e%60),s=Math.floor(t%60),c="";return n>0&&(c+=n<10?"<div>0"+n+"<small>"+r.days+"</small></div>":"<div>"+n+"<small>"+r.days+"</small></div>"),i>0&&(c+=i<10?"<div>0"+i+"<small>"+r.hours+"</small></div>":"<div>"+i+"<small>"+r.hours+"</small></div>"),l>=0&&(c+=l<10?"<div>0"+l+"<small>"+r.minutes+"</small></div>":"<div>"+l+"<small>"+r.minutes+"</small></div>"),s>=0?c+=s<10?"<div>0"+s+"<small>"+r.seconds+"</small></div>":"<div>"+s+"<small>"+r.seconds+"</small></div>":s<0&&(c="<div>00<small>"+r.minutes+"</small></div><div>00<small>"+r.seconds+"</small></div>"),c},o}();l.decorators=[{type:r.Pipe,args:[{name:"counter",pure:!0}]}];
/**
* @license
* Copyright LOGO YAZILIM SANAYİ VE TİCARET A.Ş. All Rights Reserved.
*
* Save to the extent permitted by law, you may not use, copy, modify,
* distribute or create derivative works of this material or any part
* of it without the prior written consent of LOGO YAZILIM SANAYİ VE TİCARET A.Ş. Limited.
* Any reproduction of this material must contain this notice.
*/
var s=function(){function o(){this.pausedTime=0,this.isEnded=new t.Subject}return o.prototype.prepareTimer=function(){this.timerValue=this.timerCount,this.readableTime=(new l).transform(this.timerCount,this.language),this.autoStart&&this.runTimer()},o.prototype.runTimer=function(){var o=this;clearInterval(this.timer),this.timer=setInterval((function(){o.countdown?(o.timerCount=Math.floor(o.timerCount-1e3),o.timerCount<0&&(clearInterval(o.timer),o.isEnded.next(!0))):(o.timerCount=Math.floor(o.timerCount+1e3),o.timerCount===o.endTime&&(clearInterval(o.timer),o.isEnded.next(!0))),o.pausedTime=0,o.readableTime=(new l).transform(o.timerCount,o.language)}),1e3)},o.prototype.pauseTimer=function(){0===this.pausedTime&&(this.pausedTime=this.timerCount,clearInterval(this.timer))},o.prototype.resumeTimer=function(){var o=this;setTimeout((function(){0!==o.pausedTime?(o.timerCount=o.pausedTime,o.runTimer()):o.pauseTimer()}),1e3)},o.prototype.stopTimer=function(){this.countdown?this.timerCount=0:this.timerCount=this.endTime,clearInterval(this.timer),this.readableTime=(new l).transform(this.timerCount,this.language),this.isEnded.next(!0)},o.prototype.resetTimer=function(){clearInterval(this.timer),this.timerCount=this.timerValue,this.runTimer()},o.prototype.setTime=function(o){this.timerCount=o,this.prepareTimer()},o}();s.ɵprov=i.ɵɵdefineInjectable({factory:function(){return new s},token:s,providedIn:"root"}),s.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}];
/**
* @license
* Copyright LOGO YAZILIM SANAYİ VE TİCARET A.Ş. All Rights Reserved.
*
* Save to the extent permitted by law, you may not use, copy, modify,
* distribute or create derivative works of this material or any part
* of it without the prior written consent of LOGO YAZILIM SANAYİ VE TİCARET A.Ş. Limited.
* Any reproduction of this material must contain this notice.
*/
var c=function(){function o(o){var t=this;this.timerService=o,this.isCountdown=!0,this.theme="primary",this.showIcon=!1,this.showProgressBar=!1,this.autoStart=!0,this.onTimeCompleted=new r.EventEmitter,this.watchTimer=this.timerService.isEnded.subscribe((function(o){o&&t.onTimeCompleted.emit(t.id)}))}return o.prototype.ngOnInit=function(){this.isCountdown?this.timerService.timerCount=this.timeInMs:(this.timerService.timerCount=0,this.timerService.endTime=this.timeInMs),this.timerService.autoStart=this.autoStart,this.timerService.language=this.language,this.timerService.countdown=this.isCountdown,this.timerService.prepareTimer()},o.prototype.ngOnDestroy=function(){this.watchTimer.unsubscribe()},o}();c.decorators=[{type:r.Component,args:[{selector:"logo-timer",template:'<div class="logo-timer {{cssClasses}}">\n <div *ngIf="showIcon" class="icon-base">\n <span class="le-time_clock_three"></span>\n </div>\n <div class="timer-title">\n <p>{{title}}</p>\n <div *ngIf="showProgressBar" class="progress-base">\n <logo-progress-bar\n [complete]="timeInMs"\n [cssClasses]="\'timer-progress-bar\'"\n [current]="timerService.timerCount"\n [size]="\'small\'"\n [theme]="theme"\n >\n </logo-progress-bar>\n </div>\n </div>\n <div class="timer-base {{theme}}">\n <div [innerHTML]="timerService.readableTime" class="counter"></div>\n </div>\n</div>\n',providers:[l],styles:['.dotted{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.logo-tooltip .tip.on-bottom:after,.logo-tooltip .tip.on-top:after{border-left:7px solid transparent;border-right:7px solid transparent}.logo-tooltip .tip.on-left:after,.logo-tooltip .tip.on-right:after{border-top:7px solid transparent;border-bottom:7px solid transparent}.logo-tooltip{position:relative;color:#e94a34;cursor:pointer}.logo-tooltip .tip{position:absolute;width:180px;color:#fff;font-size:14px;font-style:normal;line-height:1.4;text-align:center;border-radius:3px;background:#333;padding:8px 12px;box-sizing:border-box;cursor:auto;z-index:10;opacity:0;visibility:hidden;transition:all .25s ease-in}.logo-tooltip .tip:after{position:absolute;width:0;height:0;content:""}.logo-tooltip .tip.on-top{bottom:25px;left:0}.logo-tooltip .tip.on-top:after{bottom:-7px;left:10px;border-top:7px solid #333}.logo-tooltip .tip.on-right{top:-5px;left:103%}.logo-tooltip .tip.on-right:after{top:37%;left:-7px;border-right:7px solid #333}.logo-tooltip .tip.on-bottom{top:25px;left:0}.logo-tooltip .tip.on-bottom:after{top:-7px;left:10px;border-bottom:7px solid #333}.logo-tooltip .tip.on-left{top:-100%;right:103%}.logo-tooltip .tip.on-left:after{top:37%;right:-7px;border-left:7px solid #333}.logo-tooltip:hover .tip{opacity:1;visibility:visible}.logo-tooltip:hover .tip.on-top{transform:translateY(-15px)}.logo-tooltip:hover .tip.on-right{transform:translateX(15px)}.logo-tooltip:hover .tip.on-bottom{transform:translateY(15px)}.logo-tooltip:hover .tip.on-left{transform:translateX(-15px)}.test{content:"a";content:"ba";content:"aa";content:"aade";content:"abde"}:root .basic,:root .gray,:root .secondary{color:var(--leds-contrast-90pct)}:root .danger,:root .info,:root .success,:root .warning{color:var(--white)}:root .outline.primary,:root .outline.primary:active,:root .outline.primary:focus,:root .outline.primary:hover{border-color:var(--light-600)}:root .outline.primary:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--primary)}:root .outline.primary:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--primary)}:root .outline.primary:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--primary)}:root .outline.secondary{color:var(--leds-contrast-90pct)}:root .outline.secondary,:root .outline.secondary:active,:root .outline.secondary:focus,:root .outline.secondary:hover{border-color:var(--light-600)}:root .outline.secondary:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--leds-contrast-90pct)}:root .outline.secondary:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .outline.secondary:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .outline.basic{color:var(--leds-contrast-90pct)}:root .outline.basic,:root .outline.basic:active,:root .outline.basic:focus,:root .outline.basic:hover{border-color:var(--light-600)}:root .outline.basic:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--leds-contrast-90pct)}:root .outline.basic:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .outline.basic:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .outline.neutral,:root .outline.neutral:active,:root .outline.neutral:focus,:root .outline.neutral:hover{border-color:var(--light-600)}:root .outline.neutral:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--neutral)}:root .outline.neutral:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--neutral)}:root .outline.neutral:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--neutral)}:root .outline.light{border-color:rgba(var(--light-rgb),.5)}:root .outline.light:active,:root .outline.light:focus,:root .outline.light:hover{border-color:var(--light)}:root .outline.light:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--white)}:root .outline.light:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--white)}:root .outline.light:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--white)}:root .outline.dark,:root .outline.dark:active,:root .outline.dark:focus,:root .outline.dark:hover{border-color:var(--light-600)}:root .outline.dark:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--dark)}:root .outline.dark:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--dark)}:root .outline.dark:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--dark)}:root .outline.gray{color:var(--leds-contrast-90pct)}:root .outline.gray,:root .outline.gray:active,:root .outline.gray:focus,:root .outline.gray:hover{border-color:var(--light-600)}:root .outline.gray:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--leds-contrast-90pct)}:root .outline.gray:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .outline.gray:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .outline.info{color:var(--info)}:root .outline.info,:root .outline.info:active,:root .outline.info:focus,:root .outline.info:hover{border-color:var(--light-600)}:root .outline.info:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--info)}:root .outline.info:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--info)}:root .outline.info:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--info)}:root .outline.danger{color:var(--danger)}:root .outline.danger,:root .outline.danger:active,:root .outline.danger:focus,:root .outline.danger:hover{border-color:var(--light-600)}:root .outline.danger:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--danger)}:root .outline.danger:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--danger)}:root .outline.danger:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--danger)}:root .outline.warning{color:var(--warning)}:root .outline.warning,:root .outline.warning:active,:root .outline.warning:focus,:root .outline.warning:hover{border-color:var(--light-600)}:root .outline.warning:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--warning)}:root .outline.warning:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--warning)}:root .outline.warning:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--warning)}:root .outline.success{color:var(--success)}:root .outline.success,:root .outline.success:active,:root .outline.success:focus,:root .outline.success:hover{border-color:var(--light-600)}:root .outline.success:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--success)}:root .outline.success:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--success)}:root .outline.success:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--success)}:root .ghost.primary:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--primary)}:root .ghost.primary:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--primary)}:root .ghost.primary:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--primary)}:root .ghost.secondary,:root .ghost.secondary:hover{color:var(--leds-contrast-90pct)}:root .ghost.secondary:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover))}:root .ghost.secondary:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .ghost.secondary:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus))}:root .ghost.basic,:root .ghost.basic:hover,:root .ghost.secondary:focus{color:var(--leds-contrast-90pct)}:root .ghost.basic:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover))}:root .ghost.basic:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .ghost.basic:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .ghost.neutral:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--neutral)}:root .ghost.neutral:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--neutral)}:root .ghost.neutral:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--neutral)}:root .ghost.light:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--white)}:root .ghost.light:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--white)}:root .ghost.light:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--white)}:root .ghost.dark:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--dark)}:root .ghost.dark:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--dark)}:root .ghost.dark:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--dark)}:root .ghost.gray,:root .ghost.gray:hover{color:var(--leds-contrast-90pct)}:root .ghost.gray:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover))}:root .ghost.gray:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--leds-contrast-90pct)}:root .ghost.gray:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--leds-contrast-90pct)}:root .ghost.info{color:var(--info)}:root .ghost.info:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--info)}:root .ghost.info:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--info)}:root .ghost.info:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--info)}:root .ghost.danger{color:var(--danger)}:root .ghost.danger:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--danger)}:root .ghost.danger:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--danger)}:root .ghost.danger:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--danger)}:root .ghost.warning{color:var(--warning)}:root .ghost.warning:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--warning)}:root .ghost.warning:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--warning)}:root .ghost.warning:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--warning)}:root .ghost.success{color:var(--success)}:root .ghost.success:hover{background-color:rgba(var(--neutral-500-rgb),var(--ghost-hover));color:var(--success)}:root .ghost.success:active{background-color:rgba(var(--neutral-500-rgb),var(--ghost-active));color:var(--success)}:root .ghost.success:focus{background-color:rgba(var(--neutral-500-rgb),var(--ghost-focus));color:var(--success)}[class*=" le-"],[class^=le-]{position:relative}[class*=" le-"]:before,[class^=le-]:before{height:100%;top:0;-webkit-mask-size:20px;mask-size:20px}.le-time_clock_three:before{-webkit-mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg width=\'24\' height=\'24\' viewBox=\'0 0 24 24\' fill=\'currentColor\' xmlns=\'http://www.w3.org/2000/svg\'%3E %3Cg id=\'time_clock_three\'%3E %3Cpath id=\'Shape\' fill-rule=\'evenodd\' clip-rule=\'evenodd\' d=\'M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C21.994 6.47963 17.5204 2.00597 12 2ZM12 20.3333C7.39763 20.3333 3.66667 16.6024 3.66667 12C3.66667 7.39763 7.39763 3.66667 12 3.66667C16.6024 3.66667 20.3333 7.39763 20.3333 12C20.3283 16.6003 16.6003 20.3283 12 20.3333ZM11.5833 5.75C11.5833 5.51988 11.7699 5.33333 12 5.33333C13.8319 5.3347 15.5824 6.09038 16.8397 7.42262C18.0971 8.75487 18.7503 10.5461 18.6458 12.375C18.6337 12.6075 18.4594 12.7992 18.2292 12.8333H12C11.7699 12.8333 11.5833 12.6468 11.5833 12.4167V5.75Z\' fill=\'%235A5A5A\'/%3E %3C/g%3E %3C/svg%3E");-webkit-mask-repeat:no-repeat;-webkit-mask-position:center;display:inline-block;content:"";position:absolute;background:currentColor}:host{display:inline-block}:host .logo-timer{border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;display:flex;align-items:stretch;justify-content:flex-start;flex-wrap:nowrap;padding:7px 10px;background:var(--secondary-400);overflow:hidden}:host .logo-timer .icon-base{color:var(--basic-900)}:host .logo-timer .icon-base span{display:inline-block;width:20px;height:20px;margin-right:8px;min-width:20px!important}:host .logo-timer .icon-base span:before{width:20px}:host .logo-timer .timer-title{margin-right:10px}:host .logo-timer .timer-title p{margin-top:0!important;margin-bottom:4px!important}:host .logo-timer .timer-base{margin:-7px -10px -7px 0;flex-grow:1;padding:7px 10px;box-sizing:border-box}:host .logo-timer .timer-base .counter{display:flex;align-items:center;justify-content:space-between;flex-wrap:nowrap;flex-direction:row}:host .logo-timer .timer-base .counter ::ng-deep div{padding-right:12px;position:relative;font-size:16px;line-height:16px;font-weight:700}:host .logo-timer .timer-base .counter ::ng-deep div small{display:block;font-size:12px;line-height:10px;font-weight:400}:host .logo-timer .timer-base .counter ::ng-deep div:after{content:" : ";font-weight:700;position:absolute;font-size:16px;line-height:13px;top:0;right:4px}:host .logo-timer .timer-base .counter ::ng-deep div:last-child{padding-right:0}:host .logo-timer .timer-base .counter ::ng-deep div:last-child:after{content:"";padding:0;display:none}']}]}],c.ctorParameters=function(){return[{type:s}]},c.propDecorators={cssClasses:[{type:r.Input}],isCountdown:[{type:r.Input}],timeInMs:[{type:r.Input}],title:[{type:r.Input}],id:[{type:r.Input}],theme:[{type:r.Input}],showIcon:[{type:r.Input}],showProgressBar:[{type:r.Input}],language:[{type:r.Input}],autoStart:[{type:r.Input}],onTimeCompleted:[{type:r.Output}]};var g=function(){};g.decorators=[{type:r.NgModule,args:[{declarations:[l],imports:[e.CommonModule],exports:[l]}]}];
/**
* @license
* Copyright LOGO YAZILIM SANAYİ VE TİCARET A.Ş. All Rights Reserved.
*
* Save to the extent permitted by law, you may not use, copy, modify,
* distribute or create derivative works of this material or any part
* of it without the prior written consent of LOGO YAZILIM SANAYİ VE TİCARET A.Ş. Limited.
* Any reproduction of this material must contain this notice.
*/
var u=function(){};u.decorators=[{type:r.NgModule,args:[{declarations:[c],imports:[g,e.CommonModule,a.ProgressBarModule],exports:[c]}]}],o.TimerComponent=c,o.TimerModule=u,o.TimerService=s,o["ɵa"]=l,o["ɵb"]=g,Object.defineProperty(o,"__esModule",{value:!0})}));
//# sourceMappingURL=logo-software-timer.umd.min.js.map