UNPKG

ng2-toasty

Version:

Angular2 Toasty component shows growl-style alerts and messages for your web app

1 lines 10.3 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@angular/core"),require("@angular/common"),require("@angular/platform-browser"),require("rxjs/Subject")):"function"==typeof define&&define.amd?define(["@angular/core","@angular/common","@angular/platform-browser","rxjs/Subject"],e):"object"==typeof exports?exports["ng2-toasty"]=e(require("@angular/core"),require("@angular/common"),require("@angular/platform-browser"),require("rxjs/Subject")):t["ng2-toasty"]=e(t["@angular/core"],t["@angular/common"],t["@angular/platform-browser"],t["rxjs/Subject"])}(this,function(t,e,o,n){return function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var o={};return e.m=t,e.c=o,e.i=function(t){return t},e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=7)}([function(e,o){e.exports=t},function(t,e,o){"use strict";function n(t){return new h(t)}o.d(e,"a",function(){return f}),o.d(e,"b",function(){return l}),o.d(e,"c",function(){return p}),o.d(e,"d",function(){return r}),o.d(e,"e",function(){return d}),e.f=n,o.d(e,"g",function(){return h});var r,i=o(0),s=(o.n(i),o(5)),a=o(9),c=(o.n(a),this&&this.__decorate||function(t,e,o,n){var r,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(i<3?r(s):i>3?r(e,o,s):r(e,o))||s);return i>3&&s&&Object.defineProperty(e,o,s),s}),u=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},f=function(){function t(){}return t=c([o.i(i.Injectable)()],t)}(),l=function(){function t(){}return t=c([o.i(i.Injectable)()],t)}(),p=function(){function t(){this.limit=5,this.showClose=!0,this.position="bottom-right",this.timeout=5e3,this.theme="default"}return t=c([o.i(i.Injectable)()],t)}();!function(t){t[t.ADD=0]="ADD",t[t.CLEAR=1]="CLEAR",t[t.CLEAR_ALL=2]="CLEAR_ALL"}(r||(r={}));var d=function(){function t(t,e){this.type=t,this.value=e}return t}(),h=function(){var t=e=function(t){this.config=t,this.uniqueCounter=0,this.eventSource=new a.Subject,this.events=this.eventSource.asObservable()};return t.prototype.default=function(t){this.add(t,"default")},t.prototype.info=function(t){this.add(t,"info")},t.prototype.success=function(t){this.add(t,"success")},t.prototype.wait=function(t){this.add(t,"wait")},t.prototype.error=function(t){this.add(t,"error")},t.prototype.warning=function(t){this.add(t,"warning")},t.prototype.add=function(t,n){var i;if(!(i=o.i(s.b)(t)&&""!==t||o.i(s.c)(t)?{title:t.toString()}:t)||!i.title&&!i.msg)throw new Error("ng2-toasty: No toast title or message specified!");n=n||"default",this.uniqueCounter++;var a,c=this._checkConfigItem(this.config,i,"showClose");a=i.theme&&e.THEMES.indexOf(i.theme)>-1?i.theme:this.config.theme;var u={id:this.uniqueCounter,title:i.title,msg:i.msg,showClose:c,type:"toasty-type-"+n,theme:"toasty-theme-"+a,onAdd:i.onAdd&&o.i(s.a)(i.onAdd)?i.onAdd:null,onRemove:i.onRemove&&o.i(s.a)(i.onRemove)?i.onRemove:null};u.timeout=i.hasOwnProperty("timeout")?i.timeout:this.config.timeout,this.emitEvent(new d(r.ADD,u)),i.onAdd&&o.i(s.a)(i.onAdd)&&i.onAdd.call(this,u)},t.prototype.clearAll=function(){this.emitEvent(new d(r.CLEAR_ALL))},t.prototype.clear=function(t){this.emitEvent(new d(r.CLEAR,t))},t.prototype._checkConfigItem=function(t,e,o){return!1!==e[o]&&(!!e[o]||t[o])},t.prototype.emitEvent=function(t){this.eventSource&&this.eventSource.next(t)},t.THEMES=["default","material","bootstrap"],t=e=c([o.i(i.Injectable)(),u("design:paramtypes",[p])],t);var e}()},function(t,e,o){"use strict";o.d(e,"a",function(){return a});var n=o(8),r=(o.n(n),o(0)),i=(o.n(r),this&&this.__decorate||function(t,e,o,n){var r,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(i<3?r(s):i>3?r(e,o,s):r(e,o))||s);return i>3&&s&&Object.defineProperty(e,o,s),s}),s=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},a=function(){function t(t){this.domSanitized=t}return t.prototype.transform=function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];return this.domSanitized.bypassSecurityTrustHtml(t)},t=i([o.i(r.Pipe)({name:"safeHtml"}),s("design:paramtypes",[n.DomSanitizer])],t)}()},function(t,e,o){"use strict";o.d(e,"a",function(){return a});var n=o(0),r=(o.n(n),o(1)),i=this&&this.__decorate||function(t,e,o,n){var r,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(i<3?r(s):i>3?r(e,o,s):r(e,o))||s);return i>3&&s&&Object.defineProperty(e,o,s),s},s=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},a=function(){function t(){this.closeToastEvent=new n.EventEmitter}return t.prototype.close=function(t){t.preventDefault(),this.closeToastEvent.next(this.toast)},i([o.i(n.Input)(),s("design:type",r.b)],t.prototype,"toast",void 0),i([o.i(n.Output)("closeToast"),s("design:type",Object)],t.prototype,"closeToastEvent",void 0),t=i([o.i(n.Component)({selector:"ng2-toast",template:'\n <div class="toast" [ngClass]="[toast.type, toast.theme]">\n <div *ngIf="toast.showClose" class="close-button" (click)="close($event)"></div>\n <div *ngIf="toast.title || toast.msg" class="toast-text">\n <span *ngIf="toast.title" class="toast-title" [innerHTML]="toast.title | safeHtml"></span>\n <br *ngIf="toast.title && toast.msg" />\n <span *ngIf="toast.msg" class="toast-msg" [innerHtml]="toast.msg | safeHtml"></span>\n </div>\n </div>'})],t)}()},function(t,e,o){"use strict";o.d(e,"a",function(){return c});var n=o(0),r=(o.n(n),o(5)),i=o(1),s=this&&this.__decorate||function(t,e,o,n){var r,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(i<3?r(s):i>3?r(e,o,s):r(e,o))||s);return i>3&&s&&Object.defineProperty(e,o,s),s},a=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},c=function(){var t=e=function(t,e){this.config=t,this.toastyService=e,this._position="",this.toasts=[],this.position=""};return Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(t){if(t){for(var o=!0,n=0;n<e.POSITIONS.length;n++)if(e.POSITIONS[n]===t){o=!1;break}o&&(t=this.config.position)}else t=this.config.position;this._position="toasty-position-"+t},enumerable:!0,configurable:!0}),t.prototype.ngOnInit=function(){var t=this;this.toastyService.events.subscribe(function(e){if(e.type===i.d.ADD){var o=e.value;t.add(o)}else if(e.type===i.d.CLEAR){var n=e.value;t.clear(n)}else e.type===i.d.CLEAR_ALL&&t.clearAll()})},t.prototype.closeToast=function(t){this.clear(t.id)},t.prototype.add=function(t){this.toasts.length>=this.config.limit&&this.toasts.shift(),this.toasts.push(t),t.timeout&&this._setTimeout(t)},t.prototype.clear=function(t){var e=this;if(!t)throw new Error("Please provide id of Toast to close");this.toasts.forEach(function(n,i){n.id===t&&(n.onRemove&&o.i(r.a)(n.onRemove)&&n.onRemove.call(e,n),e.toasts.splice(i,1))})},t.prototype.clearAll=function(){var t=this;this.toasts.forEach(function(e,n){e.onRemove&&o.i(r.a)(e.onRemove)&&e.onRemove.call(t,e)}),this.toasts=[]},t.prototype._setTimeout=function(t){var e=this;window.setTimeout(function(){e.clear(t.id)},t.timeout)},t.POSITIONS=["bottom-right","bottom-left","top-right","top-left","top-center","bottom-center","center-center"],s([o.i(n.Input)(),a("design:type",String),a("design:paramtypes",[String])],t.prototype,"position",null),t=e=s([o.i(n.Component)({selector:"ng2-toasty",template:'\n <div id="toasty" [ngClass]="[position]">\n <ng2-toast *ngFor="let toast of toasts" [toast]="toast" (closeToast)="closeToast(toast)"></ng2-toast>\n </div>'}),a("design:paramtypes",[i.c,i.g])],t);var e}()},function(t,e,o){"use strict";function n(t){return"string"==typeof t}function r(t){return"number"==typeof t}function i(t){return"function"==typeof t}e.b=n,e.c=r,e.a=i},function(t,o){t.exports=e},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),o.d(e,"providers",function(){return f}),o.d(e,"ToastyModule",function(){return l});var n=o(0),r=(o.n(n),o(6)),i=(o.n(r),o(1));o.d(e,"ToastOptions",function(){return i.a}),o.d(e,"ToastData",function(){return i.b}),o.d(e,"ToastyConfig",function(){return i.c}),o.d(e,"ToastyEventType",function(){return i.d}),o.d(e,"ToastyEvent",function(){return i.e}),o.d(e,"toastyServiceFactory",function(){return i.f}),o.d(e,"ToastyService",function(){return i.g});var s=o(4);o.d(e,"ToastyComponent",function(){return s.a});var a=o(3);o.d(e,"ToastComponent",function(){return a.a});var c=o(2);o.d(e,"SafeHtmlPipe",function(){return c.a});var u=this&&this.__decorate||function(t,e,o,n){var r,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(i<3?r(s):i>3?r(e,o,s):r(e,o))||s);return i>3&&s&&Object.defineProperty(e,o,s),s},f=[i.c,{provide:i.g,useFactory:i.f,deps:[i.c]}],l=function(){var t=e=function(){};return t.forRoot=function(){return{ngModule:e,providers:f}},t=e=u([o.i(n.NgModule)({imports:[r.CommonModule],declarations:[a.a,s.a,c.a],exports:[a.a,s.a],providers:f})],t);var e}()},function(t,e){t.exports=o},function(t,e){t.exports=n}])});