diff options
Diffstat (limited to 'catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts b/catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts index e98b69003e..79d35c6e0e 100644 --- a/catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts +++ b/catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + import { Directive, ComponentRef, ViewContainerRef, ComponentFactoryResolver, Input, HostListener } from "@angular/core"; @@ -14,6 +34,7 @@ export class TooltipComponent { private tooltip: ComponentRef<TooltipContentComponent>; private visible: boolean; + private delayInProgress: boolean = false; // ------------------------------------------------------------------------- // Constructor @@ -31,6 +52,7 @@ export class TooltipComponent { @Input() tooltipDisabled: boolean; @Input() tooltipAnimation: boolean = true; @Input() tooltipPlacement: "top"|"bottom"|"left"|"right" = "bottom"; + @Input() tooltipDelay: number = 1500; // ------------------------------------------------------------------------- // Public Methods @@ -41,6 +63,11 @@ export class TooltipComponent { if(this.tooltipDisabled || this.visible || this.content === "") { return; } + if (this.tooltipDelay && !this.delayInProgress) { + this.delayInProgress = true; + setTimeout(() => { this.delayInProgress && this.show() }, this.tooltipDelay); + return; + } this.visible = true; if (typeof this.content === "string") { @@ -65,6 +92,7 @@ export class TooltipComponent { @HostListener("mouseleave") hide(): void { + this.delayInProgress = false; if (!this.visible) { return; } |