1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4 | 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;
|
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6 | };
|
7 | var __metadata = (this && this.__metadata) || function (k, v) {
|
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9 | };
|
10 | import { Directive, Input, ViewContainerRef, Output, EventEmitter, Renderer, ElementRef } from '@angular/core';
|
11 | import { TooltipContainerComponent } from './tooltip-container.component';
|
12 | import { TooltipConfig } from './tooltip.config';
|
13 | import { ComponentLoaderFactory } from '../component-loader';
|
14 | import { OnChange } from '../utils/decorators';
|
15 | export var TooltipDirective = (function () {
|
16 |
|
17 | function TooltipDirective(_viewContainerRef, _renderer, _elementRef, cis, config) {
|
18 |
|
19 | this.tooltipChange = new EventEmitter();
|
20 |
|
21 | this._animation = true;
|
22 |
|
23 | this._delay = 0;
|
24 |
|
25 | this._fadeDuration = 150;
|
26 |
|
27 | this.tooltipStateChanged = new EventEmitter();
|
28 | this._tooltip = cis
|
29 | .createLoader(_elementRef, _viewContainerRef, _renderer)
|
30 | .provide({ provide: TooltipConfig, useValue: config });
|
31 | Object.assign(this, config);
|
32 | this.onShown = this._tooltip.onShown;
|
33 | this.onHidden = this._tooltip.onHidden;
|
34 | }
|
35 | Object.defineProperty(TooltipDirective.prototype, "isOpen", {
|
36 | |
37 |
|
38 |
|
39 | get: function () { return this._tooltip.isShown; },
|
40 | set: function (value) {
|
41 | if (value) {
|
42 | this.show();
|
43 | }
|
44 | else {
|
45 | this.hide();
|
46 | }
|
47 | },
|
48 | enumerable: true,
|
49 | configurable: true
|
50 | });
|
51 | Object.defineProperty(TooltipDirective.prototype, "htmlContent", {
|
52 |
|
53 |
|
54 | set: function (value) {
|
55 | console.warn('tooltipHtml was deprecated, please use `tooltip` instead');
|
56 | this.tooltip = value;
|
57 | },
|
58 | enumerable: true,
|
59 | configurable: true
|
60 | });
|
61 | Object.defineProperty(TooltipDirective.prototype, "_placement", {
|
62 |
|
63 | set: function (value) {
|
64 | console.warn('tooltipPlacement was deprecated, please use `placement` instead');
|
65 | this.placement = value;
|
66 | },
|
67 | enumerable: true,
|
68 | configurable: true
|
69 | });
|
70 | Object.defineProperty(TooltipDirective.prototype, "_isOpen", {
|
71 | get: function () {
|
72 | console.warn('tooltipIsOpen was deprecated, please use `isOpen` instead');
|
73 | return this.isOpen;
|
74 | },
|
75 |
|
76 | set: function (value) {
|
77 | console.warn('tooltipIsOpen was deprecated, please use `isOpen` instead');
|
78 | this.isOpen = value;
|
79 | },
|
80 | enumerable: true,
|
81 | configurable: true
|
82 | });
|
83 | Object.defineProperty(TooltipDirective.prototype, "_enable", {
|
84 | get: function () {
|
85 | console.warn('tooltipEnable was deprecated, please use `isDisabled` instead');
|
86 | return this.isDisabled === true;
|
87 | },
|
88 |
|
89 | set: function (value) {
|
90 | console.warn('tooltipEnable was deprecated, please use `isDisabled` instead');
|
91 | this.isDisabled = value === true;
|
92 | },
|
93 | enumerable: true,
|
94 | configurable: true
|
95 | });
|
96 | Object.defineProperty(TooltipDirective.prototype, "_appendToBody", {
|
97 | get: function () {
|
98 | console.warn('tooltipAppendToBody was deprecated, please use `container="body"` instead');
|
99 | return this.container === 'body';
|
100 | },
|
101 |
|
102 | set: function (value) {
|
103 | console.warn('tooltipAppendToBody was deprecated, please use `container="body"` instead');
|
104 | this.container = value ? 'body' : this.container;
|
105 | },
|
106 | enumerable: true,
|
107 | configurable: true
|
108 | });
|
109 | Object.defineProperty(TooltipDirective.prototype, "_popupClass", {
|
110 |
|
111 | set: function (value) {
|
112 | console.warn('tooltipClass deprecated');
|
113 | },
|
114 | enumerable: true,
|
115 | configurable: true
|
116 | });
|
117 | Object.defineProperty(TooltipDirective.prototype, "_tooltipContext", {
|
118 |
|
119 | set: function (value) {
|
120 | console.warn('tooltipContext deprecated');
|
121 | },
|
122 | enumerable: true,
|
123 | configurable: true
|
124 | });
|
125 | Object.defineProperty(TooltipDirective.prototype, "_tooltipTrigger", {
|
126 |
|
127 | get: function () {
|
128 | console.warn('tooltipTrigger was deprecated, please use `triggers` instead');
|
129 | return this.triggers;
|
130 | },
|
131 | set: function (value) {
|
132 | console.warn('tooltipTrigger was deprecated, please use `triggers` instead');
|
133 | this.triggers = (value || '').toString();
|
134 | },
|
135 | enumerable: true,
|
136 | configurable: true
|
137 | });
|
138 | ;
|
139 | ;
|
140 | TooltipDirective.prototype.ngOnInit = function () {
|
141 | var _this = this;
|
142 | this._tooltip.listen({
|
143 | triggers: this.triggers,
|
144 | show: function () { return _this.show(); }
|
145 | });
|
146 | this.tooltipChange.subscribe(function (value) {
|
147 | if (!value) {
|
148 | _this._tooltip.hide();
|
149 | }
|
150 | });
|
151 | };
|
152 | |
153 |
|
154 |
|
155 |
|
156 | TooltipDirective.prototype.toggle = function () {
|
157 | if (this.isOpen) {
|
158 | return this.hide();
|
159 | }
|
160 | this.show();
|
161 | };
|
162 | |
163 |
|
164 |
|
165 |
|
166 | TooltipDirective.prototype.show = function () {
|
167 | var _this = this;
|
168 | if (this.isOpen || this.isDisabled || this._delayTimeoutId || !this.tooltip) {
|
169 | return;
|
170 | }
|
171 | var showTooltip = function () { return _this._tooltip
|
172 | .attach(TooltipContainerComponent)
|
173 | .to(_this.container)
|
174 | .position({ attachment: _this.placement })
|
175 | .show({
|
176 | content: _this.tooltip,
|
177 | placement: _this.placement
|
178 | }); };
|
179 | if (this._delay) {
|
180 | this._delayTimeoutId = setTimeout(function () { showTooltip(); }, this._delay);
|
181 | }
|
182 | else {
|
183 | showTooltip();
|
184 | }
|
185 | };
|
186 | |
187 |
|
188 |
|
189 |
|
190 | TooltipDirective.prototype.hide = function () {
|
191 | var _this = this;
|
192 | if (this._delayTimeoutId) {
|
193 | clearTimeout(this._delayTimeoutId);
|
194 | this._delayTimeoutId = undefined;
|
195 | }
|
196 | if (!this._tooltip.isShown) {
|
197 | return;
|
198 | }
|
199 | this._tooltip.instance.classMap.in = false;
|
200 | setTimeout(function () {
|
201 | _this._tooltip.hide();
|
202 | }, this._fadeDuration);
|
203 | };
|
204 | TooltipDirective.prototype.ngOnDestroy = function () {
|
205 | this._tooltip.dispose();
|
206 | };
|
207 | TooltipDirective.decorators = [
|
208 | { type: Directive, args: [{
|
209 | selector: '[tooltip], [tooltipHtml]',
|
210 | exportAs: 'bs-tooltip'
|
211 | },] },
|
212 | ];
|
213 |
|
214 | TooltipDirective.ctorParameters = function () { return [
|
215 | { type: ViewContainerRef, },
|
216 | { type: Renderer, },
|
217 | { type: ElementRef, },
|
218 | { type: ComponentLoaderFactory, },
|
219 | { type: TooltipConfig, },
|
220 | ]; };
|
221 | TooltipDirective.propDecorators = {
|
222 | 'tooltip': [{ type: Input },],
|
223 | 'tooltipChange': [{ type: Output },],
|
224 | 'placement': [{ type: Input },],
|
225 | 'triggers': [{ type: Input },],
|
226 | 'container': [{ type: Input },],
|
227 | 'isOpen': [{ type: Input },],
|
228 | 'isDisabled': [{ type: Input },],
|
229 | 'onShown': [{ type: Output },],
|
230 | 'onHidden': [{ type: Output },],
|
231 | 'htmlContent': [{ type: Input, args: ['tooltipHtml',] },],
|
232 | '_placement': [{ type: Input, args: ['tooltipPlacement',] },],
|
233 | '_isOpen': [{ type: Input, args: ['tooltipIsOpen',] },],
|
234 | '_enable': [{ type: Input, args: ['tooltipEnable',] },],
|
235 | '_appendToBody': [{ type: Input, args: ['tooltipAppendToBody',] },],
|
236 | '_animation': [{ type: Input, args: ['tooltipAnimation',] },],
|
237 | '_popupClass': [{ type: Input, args: ['tooltipClass',] },],
|
238 | '_tooltipContext': [{ type: Input, args: ['tooltipContext',] },],
|
239 | '_delay': [{ type: Input, args: ['tooltipPopupDelay',] },],
|
240 | '_fadeDuration': [{ type: Input, args: ['tooltipFadeDuration',] },],
|
241 | '_tooltipTrigger': [{ type: Input, args: ['tooltipTrigger',] },],
|
242 | 'tooltipStateChanged': [{ type: Output },],
|
243 | };
|
244 | __decorate([
|
245 | OnChange(),
|
246 | __metadata('design:type', Object)
|
247 | ], TooltipDirective.prototype, "tooltip", void 0);
|
248 | return TooltipDirective;
|
249 | }());
|
250 |
|
\ | No newline at end of file |