[sdc] update code of sdc
[sdc.git] / catalog-ui / src / app / ng2 / components / tooltip / tooltip.component.ts
index e98b690..891aa60 100644 (file)
@@ -14,6 +14,7 @@ export class TooltipComponent {
 
     private tooltip: ComponentRef<TooltipContentComponent>;
     private visible: boolean;
+    private delayInProgress: boolean = false;
 
     // -------------------------------------------------------------------------
     // Constructor
@@ -31,6 +32,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 +43,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 +72,7 @@ export class TooltipComponent {
 
     @HostListener("mouseleave")
     hide(): void {
+        this.delayInProgress = false;
         if (!this.visible) {
             return;
         }