ngx-bootstrap
Version:
Native Angular Bootstrap Components
149 lines (143 loc) • 4.28 kB
JavaScript
import { Directive, ElementRef, EventEmitter, HostBinding, Input, Output, Renderer2, NgModule } from '@angular/core';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class CollapseDirective {
/**
* @param {?} _el
* @param {?} _renderer
*/
constructor(_el, _renderer) {
this._el = _el;
this._renderer = _renderer;
/**
* This event fires as soon as content collapses
*/
/* tslint:disable-next-line: no-any */
this.collapsed = new EventEmitter();
/**
* This event fires as soon as content becomes visible
*/
/* tslint:disable-next-line: no-any */
this.expanded = new EventEmitter();
// shown
this.isExpanded = true;
// hidden
this.isCollapsed = false;
// stale state
this.isCollapse = true;
// animation state
this.isCollapsing = false;
}
/**
* A flag indicating visibility of content (shown or hidden)
* @param {?} value
* @return {?}
*/
set collapse(value) {
this.isExpanded = value;
this.toggle();
}
/**
* @return {?}
*/
get collapse() {
return this.isExpanded;
}
/**
* allows to manually toggle content visibility
* @return {?}
*/
toggle() {
if (this.isExpanded) {
this.hide();
}
else {
this.show();
}
}
/**
* allows to manually hide content
* @return {?}
*/
hide() {
this.isCollapse = false;
this.isCollapsing = true;
this.isExpanded = false;
this.isCollapsed = true;
this.isCollapse = true;
this.isCollapsing = false;
this.display = 'none';
this.collapsed.emit(this);
}
/**
* allows to manually show collapsed content
* @return {?}
*/
show() {
this.isCollapse = false;
this.isCollapsing = true;
this.isExpanded = true;
this.isCollapsed = false;
this.display = 'block';
// this.height = 'auto';
this.isCollapse = true;
this.isCollapsing = false;
this._renderer.setStyle(this._el.nativeElement, 'overflow', 'visible');
this._renderer.setStyle(this._el.nativeElement, 'height', 'auto');
this.expanded.emit(this);
}
}
CollapseDirective.decorators = [
{ type: Directive, args: [{
selector: '[collapse]',
exportAs: 'bs-collapse',
host: {
'[class.collapse]': 'true'
}
},] }
];
/** @nocollapse */
CollapseDirective.ctorParameters = () => [
{ type: ElementRef },
{ type: Renderer2 }
];
CollapseDirective.propDecorators = {
collapsed: [{ type: Output }],
expanded: [{ type: Output }],
display: [{ type: HostBinding, args: ['style.display',] }],
isExpanded: [{ type: HostBinding, args: ['class.in',] }, { type: HostBinding, args: ['class.show',] }, { type: HostBinding, args: ['attr.aria-expanded',] }],
isCollapsed: [{ type: HostBinding, args: ['attr.aria-hidden',] }],
isCollapse: [{ type: HostBinding, args: ['class.collapse',] }],
isCollapsing: [{ type: HostBinding, args: ['class.collapsing',] }],
collapse: [{ type: Input }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class CollapseModule {
/**
* @return {?}
*/
static forRoot() {
return { ngModule: CollapseModule, providers: [] };
}
}
CollapseModule.decorators = [
{ type: NgModule, args: [{
declarations: [CollapseDirective],
exports: [CollapseDirective]
},] }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { CollapseDirective, CollapseModule };
//# sourceMappingURL=ngx-bootstrap-collapse.js.map