angular-spinners
Version:
Easy loading spinner management for apps running Angular 2+
1 lines • 2.74 kB
JavaScript
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common"],e):e((n.ng=n.ng||{},n.ng.spinners=n.ng.spinners||{}),n.ng.core,n.ng.common)}(this,function(n,e,t){"use strict";var o=function(){function n(){this.spinnerCache=new Set}return n.prototype._register=function(n){this.spinnerCache.add(n)},n.prototype._unregister=function(n){var e=this;this.spinnerCache.forEach(function(t){t===n&&e.spinnerCache.delete(t)})},n.prototype._unregisterGroup=function(n){var e=this;this.spinnerCache.forEach(function(t){t.group===n&&e.spinnerCache.delete(t)})},n.prototype._unregisterAll=function(){this.spinnerCache.clear()},n.prototype.show=function(n){this.spinnerCache.forEach(function(e){e.name===n&&(e.show=!0)})},n.prototype.hide=function(n){this.spinnerCache.forEach(function(e){e.name===n&&(e.show=!1)})},n.prototype.showGroup=function(n){this.spinnerCache.forEach(function(e){e.group===n&&(e.show=!0)})},n.prototype.hideGroup=function(n){this.spinnerCache.forEach(function(e){e.group===n&&(e.show=!1)})},n.prototype.showAll=function(){this.spinnerCache.forEach(function(n){return n.show=!0})},n.prototype.hideAll=function(){this.spinnerCache.forEach(function(n){return n.show=!1})},n.prototype.isShowing=function(n){var e=void 0;return this.spinnerCache.forEach(function(t){t.name===n&&(e=t.show)}),e},n}();o.decorators=[{type:e.Injectable}],o.ctorParameters=function(){return[]};var r=function(){function n(n){this.spinnerService=n,this.isShowing=!1,this.showChange=new e.EventEmitter}return Object.defineProperty(n.prototype,"show",{get:function(){return this.isShowing},set:function(n){this.isShowing=n,this.showChange.emit(this.isShowing)},enumerable:!0,configurable:!0}),n.prototype.ngOnInit=function(){if(!this.name)throw new Error("Spinner must have a 'name' attribute.");this.spinnerService._register(this)},n.prototype.ngOnDestroy=function(){this.spinnerService._unregister(this)},n}();r.decorators=[{type:e.Component,args:[{selector:"spinner",template:'\n <div *ngIf="show">\n <img *ngIf="loadingImage" [src]="loadingImage" />\n <ng-content></ng-content>\n </div>\n '}]}],r.ctorParameters=function(){return[{type:o}]},r.propDecorators={name:[{type:e.Input}],group:[{type:e.Input}],loadingImage:[{type:e.Input}],show:[{type:e.Input}],showChange:[{type:e.Output}]};var i=function(){return function(){}}();i.decorators=[{type:e.NgModule,args:[{declarations:[r],imports:[t.CommonModule],exports:[r],providers:[o]}]}],i.ctorParameters=function(){return[]},n.SpinnerComponent=r,n.SpinnerService=o,n.SpinnerModule=i,Object.defineProperty(n,"__esModule",{value:!0})});