UNPKG

ng2-bootstrap

Version:
250 lines 9.97 kB
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 { Directive, Input, ViewContainerRef, Output, EventEmitter, Renderer, ElementRef } from '@angular/core'; import { TooltipContainerComponent } from './tooltip-container.component'; import { TooltipConfig } from './tooltip.config'; import { ComponentLoaderFactory } from '../component-loader'; import { OnChange } from '../utils/decorators'; export var TooltipDirective = (function () { // tslint:disable-next-line function TooltipDirective(_viewContainerRef, _renderer, _elementRef, cis, config) { /** Fired when tooltip content changes */ this.tooltipChange = new EventEmitter(); /** @deprecated - removed, will be added to configuration */ this._animation = true; /** @deprecated */ this._delay = 0; /** @deprecated */ this._fadeDuration = 150; /** @deprecated */ this.tooltipStateChanged = new EventEmitter(); this._tooltip = cis .createLoader(_elementRef, _viewContainerRef, _renderer) .provide({ provide: TooltipConfig, useValue: config }); Object.assign(this, config); this.onShown = this._tooltip.onShown; this.onHidden = this._tooltip.onHidden; } Object.defineProperty(TooltipDirective.prototype, "isOpen", { /** * Returns whether or not the tooltip is currently being shown */ get: function () { return this._tooltip.isShown; }, set: function (value) { if (value) { this.show(); } else { this.hide(); } }, enumerable: true, configurable: true }); Object.defineProperty(TooltipDirective.prototype, "htmlContent", { /* tslint:disable */ /** @deprecated - please use `tooltip` instead */ set: function (value) { console.warn('tooltipHtml was deprecated, please use `tooltip` instead'); this.tooltip = value; }, enumerable: true, configurable: true }); Object.defineProperty(TooltipDirective.prototype, "_placement", { /** @deprecated - please use `placement` instead */ set: function (value) { console.warn('tooltipPlacement was deprecated, please use `placement` instead'); this.placement = value; }, enumerable: true, configurable: true }); Object.defineProperty(TooltipDirective.prototype, "_isOpen", { get: function () { console.warn('tooltipIsOpen was deprecated, please use `isOpen` instead'); return this.isOpen; }, /** @deprecated - please use `isOpen` instead*/ set: function (value) { console.warn('tooltipIsOpen was deprecated, please use `isOpen` instead'); this.isOpen = value; }, enumerable: true, configurable: true }); Object.defineProperty(TooltipDirective.prototype, "_enable", { get: function () { console.warn('tooltipEnable was deprecated, please use `isDisabled` instead'); return this.isDisabled === true; }, /** @deprecated - please use `isDisabled` instead */ set: function (value) { console.warn('tooltipEnable was deprecated, please use `isDisabled` instead'); this.isDisabled = value === true; }, enumerable: true, configurable: true }); Object.defineProperty(TooltipDirective.prototype, "_appendToBody", { get: function () { console.warn('tooltipAppendToBody was deprecated, please use `container="body"` instead'); return this.container === 'body'; }, /** @deprecated - please use `container="body"` instead */ set: function (value) { console.warn('tooltipAppendToBody was deprecated, please use `container="body"` instead'); this.container = value ? 'body' : this.container; }, enumerable: true, configurable: true }); Object.defineProperty(TooltipDirective.prototype, "_popupClass", { /** @deprecated - will replaced with customClass */ set: function (value) { console.warn('tooltipClass deprecated'); }, enumerable: true, configurable: true }); Object.defineProperty(TooltipDirective.prototype, "_tooltipContext", { /** @deprecated - removed */ set: function (value) { console.warn('tooltipContext deprecated'); }, enumerable: true, configurable: true }); Object.defineProperty(TooltipDirective.prototype, "_tooltipTrigger", { /** @deprecated - please use `triggers` instead */ get: function () { console.warn('tooltipTrigger was deprecated, please use `triggers` instead'); return this.triggers; }, set: function (value) { console.warn('tooltipTrigger was deprecated, please use `triggers` instead'); this.triggers = (value || '').toString(); }, enumerable: true, configurable: true }); ; ; TooltipDirective.prototype.ngOnInit = function () { var _this = this; this._tooltip.listen({ triggers: this.triggers, show: function () { return _this.show(); } }); this.tooltipChange.subscribe(function (value) { if (!value) { _this._tooltip.hide(); } }); }; /** * Toggles an element’s tooltip. This is considered a “manual” triggering of * the tooltip. */ TooltipDirective.prototype.toggle = function () { if (this.isOpen) { return this.hide(); } this.show(); }; /** * Opens an element’s tooltip. This is considered a “manual” triggering of * the tooltip. */ TooltipDirective.prototype.show = function () { var _this = this; if (this.isOpen || this.isDisabled || this._delayTimeoutId || !this.tooltip) { return; } var showTooltip = function () { return _this._tooltip .attach(TooltipContainerComponent) .to(_this.container) .position({ attachment: _this.placement }) .show({ content: _this.tooltip, placement: _this.placement }); }; if (this._delay) { this._delayTimeoutId = setTimeout(function () { showTooltip(); }, this._delay); } else { showTooltip(); } }; /** * Closes an element’s tooltip. This is considered a “manual” triggering of * the tooltip. */ TooltipDirective.prototype.hide = function () { var _this = this; if (this._delayTimeoutId) { clearTimeout(this._delayTimeoutId); this._delayTimeoutId = undefined; } if (!this._tooltip.isShown) { return; } this._tooltip.instance.classMap.in = false; setTimeout(function () { _this._tooltip.hide(); }, this._fadeDuration); }; TooltipDirective.prototype.ngOnDestroy = function () { this._tooltip.dispose(); }; TooltipDirective.decorators = [ { type: Directive, args: [{ selector: '[tooltip], [tooltipHtml]', exportAs: 'bs-tooltip' },] }, ]; /** @nocollapse */ TooltipDirective.ctorParameters = function () { return [ { type: ViewContainerRef, }, { type: Renderer, }, { type: ElementRef, }, { type: ComponentLoaderFactory, }, { type: TooltipConfig, }, ]; }; TooltipDirective.propDecorators = { 'tooltip': [{ type: Input },], 'tooltipChange': [{ type: Output },], 'placement': [{ type: Input },], 'triggers': [{ type: Input },], 'container': [{ type: Input },], 'isOpen': [{ type: Input },], 'isDisabled': [{ type: Input },], 'onShown': [{ type: Output },], 'onHidden': [{ type: Output },], 'htmlContent': [{ type: Input, args: ['tooltipHtml',] },], '_placement': [{ type: Input, args: ['tooltipPlacement',] },], '_isOpen': [{ type: Input, args: ['tooltipIsOpen',] },], '_enable': [{ type: Input, args: ['tooltipEnable',] },], '_appendToBody': [{ type: Input, args: ['tooltipAppendToBody',] },], '_animation': [{ type: Input, args: ['tooltipAnimation',] },], '_popupClass': [{ type: Input, args: ['tooltipClass',] },], '_tooltipContext': [{ type: Input, args: ['tooltipContext',] },], '_delay': [{ type: Input, args: ['tooltipPopupDelay',] },], '_fadeDuration': [{ type: Input, args: ['tooltipFadeDuration',] },], '_tooltipTrigger': [{ type: Input, args: ['tooltipTrigger',] },], 'tooltipStateChanged': [{ type: Output },], }; __decorate([ OnChange(), __metadata('design:type', Object) ], TooltipDirective.prototype, "tooltip", void 0); return TooltipDirective; }()); //# sourceMappingURL=tooltip.directive.js.map