ngx-bootstrap
Version:
Native Angular Bootstrap Components
99 lines • 4.66 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { AlertConfig } from './alert.config';
import { OnChange } from '../utils/decorators';
var AlertComponent = /** @class */ (function () {
function AlertComponent(_config, changeDetection) {
var _this = this;
this.changeDetection = changeDetection;
/** Alert type.
* Provides one of four bootstrap supported contextual classes:
* `success`, `info`, `warning` and `danger`
*/
this.type = 'warning';
/** If set, displays an inline "Close" button */
this.dismissible = false;
/** Is alert visible */
this.isOpen = true;
/** This event fires immediately after close instance method is called,
* $event is an instance of Alert component.
*/
this.onClose = new EventEmitter();
/** This event fires when alert closed, $event is an instance of Alert component */
this.onClosed = new EventEmitter();
this.classes = '';
this.dismissibleChange = new EventEmitter();
Object.assign(this, _config);
this.dismissibleChange.subscribe(function (dismissible) {
_this.classes = _this.dismissible ? 'alert-dismissible' : '';
_this.changeDetection.markForCheck();
});
}
AlertComponent.prototype.ngOnInit = function () {
var _this = this;
if (this.dismissOnTimeout) {
// if dismissOnTimeout used as attr without binding, it will be a string
setTimeout(function () { return _this.close(); }, parseInt(this.dismissOnTimeout, 10));
}
};
// todo: animation ` If the .fade and .in classes are present on the element,
// the alert will fade out before it is removed`
/**
* Closes an alert by removing it from the DOM.
*/
// todo: animation ` If the .fade and .in classes are present on the element,
// the alert will fade out before it is removed`
/**
* Closes an alert by removing it from the DOM.
*/
AlertComponent.prototype.close =
// todo: animation ` If the .fade and .in classes are present on the element,
// the alert will fade out before it is removed`
/**
* Closes an alert by removing it from the DOM.
*/
function () {
if (!this.isOpen) {
return;
}
this.onClose.emit(this);
this.isOpen = false;
this.changeDetection.markForCheck();
this.onClosed.emit(this);
};
AlertComponent.decorators = [
{ type: Component, args: [{
selector: 'alert,bs-alert',
template: "<ng-template [ngIf]=\"isOpen\"> <div [class]=\"'alert alert-' + type\" role=\"alert\" [ngClass]=\"classes\"> <ng-template [ngIf]=\"dismissible\"> <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"close()\"> <span aria-hidden=\"true\">×</span> <span class=\"sr-only\">Close</span> </button> </ng-template> <ng-content></ng-content> </div> </ng-template> ",
changeDetection: ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
AlertComponent.ctorParameters = function () { return [
{ type: AlertConfig, },
{ type: ChangeDetectorRef, },
]; };
AlertComponent.propDecorators = {
"type": [{ type: Input },],
"dismissible": [{ type: Input },],
"dismissOnTimeout": [{ type: Input },],
"isOpen": [{ type: Input },],
"onClose": [{ type: Output },],
"onClosed": [{ type: Output },],
};
__decorate([
OnChange(),
__metadata("design:type", Object)
], AlertComponent.prototype, "dismissible", void 0);
return AlertComponent;
}());
export { AlertComponent };
//# sourceMappingURL=alert.component.js.map