| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- import { Injectable, Component, ChangeDetectionStrategy, Input, Directive, ElementRef, Renderer2, ViewContainerRef, Output, NgModule } from '@angular/core';
- import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
- import { isBs3 } from 'ngx-bootstrap/utils';
- import { PositioningService } from 'ngx-bootstrap/positioning';
- import { CommonModule } from '@angular/common';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Configuration service for the Popover directive.
- * You can inject this service, typically in your root component, and customize
- * the values of its properties in order to provide default values for all the
- * popovers used in the application.
- */
- var PopoverConfig = /** @class */ (function () {
- function PopoverConfig() {
- /**
- * sets disable adaptive position
- */
- this.adaptivePosition = true;
- /**
- * Placement of a popover. Accepts: "top", "bottom", "left", "right", "auto"
- */
- this.placement = 'top';
- /**
- * Specifies events that should trigger. Supports a space separated list of
- * event names.
- */
- this.triggers = 'click';
- this.outsideClick = false;
- }
- PopoverConfig.decorators = [
- { type: Injectable }
- ];
- return PopoverConfig;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var PopoverContainerComponent = /** @class */ (function () {
- function PopoverContainerComponent(config) {
- Object.assign(this, config);
- }
- Object.defineProperty(PopoverContainerComponent.prototype, "isBs3", {
- get: /**
- * @return {?}
- */
- function () {
- return isBs3();
- },
- enumerable: true,
- configurable: true
- });
- PopoverContainerComponent.decorators = [
- { type: Component, args: [{
- selector: 'popover-container',
- changeDetection: ChangeDetectionStrategy.OnPush,
- // tslint:disable-next-line
- host: {
- '[class]': '"popover in popover-" + placement + " " + "bs-popover-" + placement + " " + placement + " " + containerClass',
- '[class.show]': '!isBs3',
- '[class.bs3]': 'isBs3',
- role: 'tooltip',
- style: 'display:block;'
- },
- template: "<div class=\"popover-arrow arrow\"></div>\n<h3 class=\"popover-title popover-header\" *ngIf=\"title\">{{ title }}</h3>\n<div class=\"popover-content popover-body\">\n <ng-content></ng-content>\n</div>\n",
- styles: ["\n :host.bs3.popover-top {\n margin-bottom: 10px;\n }\n :host.bs3.popover.top>.arrow {\n margin-left: -2px;\n }\n :host.bs3.popover.top {\n margin-bottom: 10px;\n }\n :host.popover.bottom>.arrow {\n margin-left: -4px;\n }\n :host.bs3.bs-popover-left {\n margin-right: .5rem;\n }\n :host.bs3.bs-popover-right .arrow, :host.bs3.bs-popover-left .arrow{\n margin: .3rem 0;\n }\n "]
- }] }
- ];
- /** @nocollapse */
- PopoverContainerComponent.ctorParameters = function () { return [
- { type: PopoverConfig }
- ]; };
- PopoverContainerComponent.propDecorators = {
- placement: [{ type: Input }],
- title: [{ type: Input }]
- };
- return PopoverContainerComponent;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * A lightweight, extensible directive for fancy popover creation.
- */
- var PopoverDirective = /** @class */ (function () {
- function PopoverDirective(_config, _elementRef, _renderer, _viewContainerRef, cis, _positionService) {
- this._positionService = _positionService;
- /**
- * Close popover on outside click
- */
- this.outsideClick = false;
- /**
- * Css class for popover container
- */
- this.containerClass = '';
- this._isInited = false;
- this._popover = cis
- .createLoader(_elementRef, _viewContainerRef, _renderer)
- .provide({ provide: PopoverConfig, useValue: _config });
- Object.assign(this, _config);
- this.onShown = this._popover.onShown;
- this.onHidden = this._popover.onHidden;
- // fix: no focus on button on Mac OS #1795
- if (typeof window !== 'undefined') {
- _elementRef.nativeElement.addEventListener('click', (/**
- * @return {?}
- */
- function () {
- try {
- _elementRef.nativeElement.focus();
- }
- catch (err) {
- return;
- }
- }));
- }
- }
- Object.defineProperty(PopoverDirective.prototype, "isOpen", {
- /**
- * Returns whether or not the popover is currently being shown
- */
- get: /**
- * Returns whether or not the popover is currently being shown
- * @return {?}
- */
- function () {
- return this._popover.isShown;
- },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- if (value) {
- this.show();
- }
- else {
- this.hide();
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Opens an element’s popover. This is considered a “manual” triggering of
- * the popover.
- */
- /**
- * Opens an element’s popover. This is considered a “manual” triggering of
- * the popover.
- * @return {?}
- */
- PopoverDirective.prototype.show = /**
- * Opens an element’s popover. This is considered a “manual” triggering of
- * the popover.
- * @return {?}
- */
- function () {
- if (this._popover.isShown || !this.popover) {
- return;
- }
- this._positionService.setOptions({
- modifiers: {
- flip: {
- enabled: this.adaptivePosition
- },
- preventOverflow: {
- enabled: this.adaptivePosition
- }
- }
- });
- this._popover
- .attach(PopoverContainerComponent)
- .to(this.container)
- .position({ attachment: this.placement })
- .show({
- content: this.popover,
- context: this.popoverContext,
- placement: this.placement,
- title: this.popoverTitle,
- containerClass: this.containerClass
- });
- if (!this.adaptivePosition) {
- this._positionService.calcPosition();
- this._positionService.deletePositionElement(this._popover._componentRef.location);
- }
- this.isOpen = true;
- };
- /**
- * Closes an element’s popover. This is considered a “manual” triggering of
- * the popover.
- */
- /**
- * Closes an element’s popover. This is considered a “manual” triggering of
- * the popover.
- * @return {?}
- */
- PopoverDirective.prototype.hide = /**
- * Closes an element’s popover. This is considered a “manual” triggering of
- * the popover.
- * @return {?}
- */
- function () {
- if (this.isOpen) {
- this._popover.hide();
- this.isOpen = false;
- }
- };
- /**
- * Toggles an element’s popover. This is considered a “manual” triggering of
- * the popover.
- */
- /**
- * Toggles an element’s popover. This is considered a “manual” triggering of
- * the popover.
- * @return {?}
- */
- PopoverDirective.prototype.toggle = /**
- * Toggles an element’s popover. This is considered a “manual” triggering of
- * the popover.
- * @return {?}
- */
- function () {
- if (this.isOpen) {
- return this.hide();
- }
- this.show();
- };
- /**
- * @return {?}
- */
- PopoverDirective.prototype.ngOnInit = /**
- * @return {?}
- */
- function () {
- var _this = this;
- // fix: seems there are an issue with `routerLinkActive`
- // which result in duplicated call ngOnInit without call to ngOnDestroy
- // read more: https://github.com/valor-software/ngx-bootstrap/issues/1885
- if (this._isInited) {
- return;
- }
- this._isInited = true;
- this._popover.listen({
- triggers: this.triggers,
- outsideClick: this.outsideClick,
- show: (/**
- * @return {?}
- */
- function () { return _this.show(); })
- });
- };
- /**
- * @return {?}
- */
- PopoverDirective.prototype.ngOnDestroy = /**
- * @return {?}
- */
- function () {
- this._popover.dispose();
- };
- PopoverDirective.decorators = [
- { type: Directive, args: [{ selector: '[popover]', exportAs: 'bs-popover' },] }
- ];
- /** @nocollapse */
- PopoverDirective.ctorParameters = function () { return [
- { type: PopoverConfig },
- { type: ElementRef },
- { type: Renderer2 },
- { type: ViewContainerRef },
- { type: ComponentLoaderFactory },
- { type: PositioningService }
- ]; };
- PopoverDirective.propDecorators = {
- adaptivePosition: [{ type: Input }],
- popover: [{ type: Input }],
- popoverContext: [{ type: Input }],
- popoverTitle: [{ type: Input }],
- placement: [{ type: Input }],
- outsideClick: [{ type: Input }],
- triggers: [{ type: Input }],
- container: [{ type: Input }],
- containerClass: [{ type: Input }],
- isOpen: [{ type: Input }],
- onShown: [{ type: Output }],
- onHidden: [{ type: Output }]
- };
- return PopoverDirective;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var PopoverModule = /** @class */ (function () {
- function PopoverModule() {
- }
- /**
- * @return {?}
- */
- PopoverModule.forRoot = /**
- * @return {?}
- */
- function () {
- return {
- ngModule: PopoverModule,
- providers: [PopoverConfig, ComponentLoaderFactory, PositioningService]
- };
- };
- PopoverModule.decorators = [
- { type: NgModule, args: [{
- imports: [CommonModule],
- declarations: [PopoverDirective, PopoverContainerComponent],
- exports: [PopoverDirective],
- entryComponents: [PopoverContainerComponent]
- },] }
- ];
- return PopoverModule;
- }());
- export { PopoverConfig, PopoverContainerComponent, PopoverDirective, PopoverModule };
- //# sourceMappingURL=ngx-bootstrap-popover.js.map
|