UNPKG

ng-pop-alert

Version:

This is an angular Notification or Alert . it help you to notify messages to users of your application in every state it is required.

3 lines (2 loc) 6.92 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs/Subject"),require("rxjs/Observable"),require("rxjs/add/observable/from"),require("@angular/common"),require("@angular/http"),require("@angular/platform-browser")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/Subject","rxjs/Observable","rxjs/add/observable/from","@angular/common","@angular/http","@angular/platform-browser"],e):e(t["ng-pop-alert"]={},t.ng.core,t.Rx,t.Rx,t.Rx.Observable,t.ng.common,t.ng.http,t.ng.platformBrowser)}(this,function(t,e,r,n,o,a,s,i){"use strict";var l=function(){function t(){}return t.prototype.message=function(t,e){var r="";return t&&t.constructor===Object?r=this.processObj(t):t&&t.constructor===Array&&(r=this.processArray(t)),r||e},t.prototype.processObj=function(t){var e=this,r="";return Object.keys(t).forEach(function(n){t[n]&&t[n].constructor===String?r+=t[n]+". <br>":t[n]&&t[n].constructor===Object?r+=e.processObj(n):t[n]&&t[n].constructor===Array&&(r+=e.processArray(t[n]))}),r},t.prototype.processArray=function(t){var e=this,r="";return t.forEach(function(t){t&&t.constructor===String?r+=t+". <br>":t&&t.constructor===Object?r+=e.processObj(t):t&&t.constructor===Array&&(r+=e.processArray(t))}),r},t}();l.decorators=[{type:e.Injectable}],l.ctorParameters=function(){return[]};var c=function(){function t(){var t=this;this.listeners={},this.eventsSubject=new r.Subject,this.events=n.Observable.from(this.eventsSubject),this.events.subscribe(function(e){var r=e.name,n=e.args;if(t.listeners[r])for(var o=0,a=t.listeners[r];o<a.length;o++){a[o].apply(void 0,n)}})}return t.prototype.on=function(t,e){this.listeners[t]||(this.listeners[t]=[],this.listeners[t].push(e)),this.listeners[t]&&(this.listeners[t][0]=e)},t.prototype.broadcast=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.eventsSubject.next({name:t,args:e})},t}();c.decorators=[{type:e.Injectable}],c.ctorParameters=function(){return[]};var u=function(){function t(t,e){this.validationError=t,this.alertEventService=e,this.alert={visible:!1,message:"",type:"",alert_class:""}}return t.prototype.success=function(t){return this.alert.alert_class="alert alert-success animated fadeIn",this.alert.message=t,this.alert.visible=!0,this.alert.type="success",this.alertEventService.broadcast("AlertMessage",this.alert),this.alert},t.prototype.info=function(t){return this.alert.alert_class="alert alert-info animated fadeIn",this.alert.message=t,this.alert.visible=!0,this.alert.type="info",this.alertEventService.broadcast("AlertMessage",this.alert),this.alert},t.prototype.warning=function(t){return this.alert.alert_class="alert alert-warning animated fadeIn",this.alert.message=t,this.alert.visible=!0,this.alert.type="warning",this.alertEventService.broadcast("AlertMessage",this.alert),this.alert},t.prototype.error=function(t,e){return this.alert.alert_class="alert alert-danger animated fadeIn",this.alert.message=t,e&&(this.alert.message=this.showError(e,t)),this.alert.visible=!0,this.alert.type="error",this.alertEventService.broadcast("AlertMessage",this.alert),this.alert},t.prototype.clear=function(){this.alertEventService.broadcast("closeAlertMessage",new Date)},t.prototype.showError=function(t,e){return t.constructor===Object||t.constructor===Array?this.validationError.message(t,e):(t=t.constructor===String?t:e)||e||t.statusText||"Error encountered while processing request, please try again."},t}();u.decorators=[{type:e.Injectable}],u.ctorParameters=function(){return[{type:l},{type:c}]};var p={duration:1e4},d=function(){function t(t,e){this.sanitizer=t,this.alertEventService=e,this.overlay=!0,this.styles={},this.alert={visible:!1,message:"",type:"",alert_class:""},this.message=""}return t.prototype.closeAlert=function(){var t=this;this.alertClosure=setTimeout(function(){t.alert.visible=!1},p.duration)},t.prototype.ngOnInit=function(){var t=this;this.alertEventService.on("AlertMessage",function(e){clearTimeout(t.alertClosure),setTimeout(function(){t.alert=e,console.log("duration=",p.duration),t.message=t.sanitizer.bypassSecurityTrustHtml(t.alert.message),t.closeAlert()},200)}),this.alertEventService.on("closeAlertMessage",function(){t.alert.visible=!1,clearTimeout(t.alertClosure)})},t}();d.decorators=[{type:e.Component,args:[{selector:"ng-pop-alert",template:'\n <div [class.notification-display]="overlay" class="bordered" [ngStyle]="styles" [hidden]="!alert[\'visible\']">\n <div class="{{alert[\'alert_class\']}}" role="alert" align="left" style="position: relative; padding: 10px;">\n <a role="button" (click)="alert[\'visible\']=false" class="pull-right alert-link" style="cursor: pointer;">&nbsp;<b>&times;</b> </a>\n <span style="font-size:13px;" [innerHTML]="message"></span>\n </div>\n </div>\n ',styles:["\n div.bordered {\n border-radius: 5px;\n -moz-border-radius: 5px;\n -webkit-border-radius: 5px;\n }\n\n div.alert-success {\n color: #3c763d !important;\n background-color: #dff0d8 !important;\n border-color: #d6e9c6 !important;\n }\n\n div.alert-success > a, div.alert-success > span {\n text-decoration: none !important;\n color: #3c763d !important;\n }\n\n div.alert-warning {\n color: #8a6d3b !important;\n background-color: #fcf8e3 !important;\n border-color: #faebcc !important;\n }\n\n div.alert-warning > a, div.alert-warning > span {\n text-decoration: none !important;\n color: #8a6d3b !important;\n }\n\n div .alert-danger {\n color: #a94442 !important;\n background-color: #f2dede !important;\n border-color: #ebccd1 !important;\n }\n\n div.alert-danger > a, div.alert-danger > span {\n text-decoration: none !important;\n color: #a94442 !important;\n }\n\n div.alert-info {\n color: #31708f !important;\n background-color: #d9edf7 !important;\n border-color: #bce8f1 !important;\n }\n\n div.alert-info > a, div.alert-info > span {\n text-decoration: none !important;\n color: #31708f !important;\n }\n\n .notification-display {\n position: fixed;\n min-width: 100px;\n width: auto !important;\n top: 10px;\n right: 10px;\n z-index: 100000 !important;\n }\n "]}]}],d.ctorParameters=function(){return[{type:i.DomSanitizer},{type:c}]},d.propDecorators={overlay:[{type:e.Input}],styles:[{type:e.Input}]};var f=function(){function t(){}return t.forRoot=function(){return{ngModule:t,providers:[u,c,l]}},t}();f.decorators=[{type:e.NgModule,args:[{imports:[s.HttpModule,a.CommonModule],declarations:[d],exports:[d]}]}],f.ctorParameters=function(){return[]},t.NgPopAlertService=u,t.NG_POP_ALERT_CONF=p,t.NgPopAlertModule=f,t.ɵb=c,t.ɵc=d,t.ɵa=l,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ng-pop-alert.umd.min.js.map