File

projects/i-components/src/lib/directives/tooltip.directive.ts

Description

The tooltip directive

Implements

OnInit AfterContentInit

Metadata

Selector [wmTooltip]

Index

Properties
Methods
Inputs
Accessors

Constructor

constructor(elementRef: ElementRef)

Constructor.

Parameters :
Name Type Optional
elementRef ElementRef No

Inputs

model
Type : any

Property that intercepts a model

wmTooltip
Type : any

Property used to set the component´s tooltip value

Methods

ngAfterContentInit
ngAfterContentInit()

After content init method

Returns : void
ngOnInit
ngOnInit()

Ng OnInit method

Returns : void
setTooltip
setTooltip()

Method which update the value of the top property to the model using the internal directive value

Returns : void

Properties

Private dirTooltipValue
Type : any

Directive internal value for the tooltip property

model
Type : any
Decorators :
@Input()

Property that intercepts a model

Private renderingFlag
Default value : true

Rendering flag for tooltip directive

Private tooltipService
Type : ToolTipService

Holds the TooltipService instance for the current component

Accessors

wmTooltip
setwmTooltip(value: any)

Property used to set the component´s tooltip value

Parameters :
Name Type Optional
value any No
Returns : void
import {
  Directive,
  Input,
  ElementRef,
  AfterContentInit,
  OnInit,
} from '@angular/core';
import {
  BaseDirective,
  FrameworkElement,
  setDependencyPropertyValue,
  ToolTipService,
} from '@mobilize/wms-framework';

/**
 * The tooltip directive
 *
 * @export
 * @class TooltipDirective
 * @extends {BaseDirective}
 * @implements {OnInit}
 * @implements {AfterContentInit}
 */
@Directive({
  selector: '[wmTooltip]',
})
export class TooltipDirective
  extends BaseDirective
  implements OnInit, AfterContentInit
{
  /**
   * Property that intercepts a model
   *
   * @type {*}
   * @memberof TooltipDirective
   */
  @Input()
  model: any;

  /**
   * Directive internal value for the tooltip property
   *
   * @private
   * @type {*}
   * @memberof TooltipDirective
   */
  private dirTooltipValue: any;

  /**
   * Rendering flag for tooltip directive
   *
   * @private
   * @memberof TooltipDirective
   */
  private renderingFlag = true;

  /**
   * Holds the TooltipService instance
   * for the current component
   *
   * @private
   * @type {TooltipService}
   * @memberof TooltipDirective
   */
  private tooltipService: ToolTipService;

  /**
   * Property used to set the component´s tooltip value
   *
   * @type {number}
   * @memberof TooltipDirective
   */
  @Input() set wmTooltip(value: any) {
    this.dirTooltipValue = value;
    if (!this.renderingFlag) {
      this.setTooltip();
    }
  }

  /**
   * Constructor.
   *
   * @memberof TooltipDirective
   */
  /* istanbul ignore next */
  constructor(private elementRef: ElementRef) {
    super();
  }

  /**
   * Method which update the value of the top property to the model using the internal directive value
   *
   * @returns
   * @memberof TooltipDirective
   */
  setTooltip(): void {
    if (this.dirTooltipValue && this.model instanceof FrameworkElement) {
      setDependencyPropertyValue(
        ToolTipService.ToolTipProperty,
        this.dirTooltipValue,
        this.model
      );
    }
  }

  /**
   * After content init method
   *
   * @memberof TooltipDirective
   */
  ngAfterContentInit() {
    this.renderingFlag = false;
    this.loadModel(this.elementRef);
    this.setTooltip();
  }

  /**
   * Ng OnInit method
   *
   * @memberof TooltipDirective
   */
  ngOnInit(): void {
    this.tooltipService = new ToolTipService();
  }
}

result-matching ""

    No results matching ""