{"version":3,"sources":["../../src/app/components/tooltip/tooltip.ts"],"names":["Tooltip","el","zone","this","tooltipPosition","tooltipEvent","appendTo","tooltipZIndex","escape","Object","defineProperty","prototype","_disabled","val","deactivate","ngAfterViewInit","_this","runOutsideAngular","mouseEnterListener","onMouseEnter","bind","mouseLeaveListener","onMouseLeave","clickListener","onClick","nativeElement","addEventListener","focusListener","onFocus","blurListener","onBlur","e","container","showTimeout","activate","active","clearHideTimeout","showDelay","setTimeout","show","life","duration","hideTimeout","hide","clearShowTimeout","hideDelay","_text","text","offsetParent","updateText","align","create","remove","document","createElement","tooltipArrow","className","appendChild","tooltipText","positionStyle","style","position","body","DomHandler","display","disabled","fadeIn","zIndex","zindex","bindDocumentResizeListener","bindScrollListener","innerHTML","createTextNode","alignTop","isOutOfBounds","alignBottom","alignRight","alignLeft","getHostOffset","offset","getBoundingClientRect","left","getWindowScrollLeft","top","getWindowScrollTop","preAlign","hostOffset","getOuterWidth","getOuterHeight","defaultClassName","tooltipStyleClass","targetTop","targetLeft","width","height","viewport","getViewport","onWindowResize","resizeListener","window","unbindDocumentResizeListener","removeEventListener","scrollHandler","ConnectedOverlayScrollHandler","unbindScrollListener","unbindEvents","parentElement","removeChild","clearTimeouts","clearTimeout","ngOnDestroy","destroy","Directive","args","selector","ElementRef","NgZone","Input","NgModule","imports","CommonModule","exports","declarations"],"mappings":"ydAmEI,SAAAA,EAAmBC,EAAuBC,GAAvBC,KAAAF,GAAAA,EAAuBE,KAAAD,KAAAA,EA1DjCC,KAAAC,gBAA0B,QAE1BD,KAAAE,aAAuB,QAEvBF,KAAAG,SAAgB,OAMhBH,KAAAI,cAAwB,OAExBJ,KAAAK,QAAkB,SAQ3BC,OAAAC,eAA8BV,EAAAW,UAAA,WAAQ,KAAtC,WACI,OAAOR,KAAKS,eAEhB,SAAaC,GACTV,KAAKS,UAAYC,EACjBV,KAAKW,8CAmCTd,EAAAW,UAAAI,gBAAA,WAAA,IAAAC,EAAAb,KACIA,KAAKD,KAAK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,UACnB5G,KAAKmG,cAAgB,gCA7bhCU,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,0DALgBC,EAAAA,kBAA6CC,EAAAA,mDAStEC,EAAAA,4BAEAA,EAAAA,wBAEAA,EAAAA,6BAEAA,EAAAA,iCAEAA,EAAAA,6BAEAA,EAAAA,sBAEAA,EAAAA,yBAEAA,EAAAA,yBAEAA,EAAAA,oBAEAA,EAAAA,wBAEAA,EAAAA,MAAKJ,KAAA,CAAC,iCAiHNI,EAAAA,MAAKJ,KAAA,CAAC,qBA6TX,iCALCK,EAAAA,SAAQL,KAAA,CAAC,CACNM,QAAS,CAACC,EAAAA,cACVC,QAAS,CAACzH,GACV0H,aAAc,CAAC1H","sourcesContent":["import { NgModule, Directive, ElementRef, AfterViewInit, OnDestroy, Input, NgZone } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DomHandler, ConnectedOverlayScrollHandler } from 'primeng/dom';\n\n@Directive({\n selector: '[pTooltip]'\n})\nexport class Tooltip implements AfterViewInit, OnDestroy {\n\n @Input() tooltipPosition: string = 'right';\n\n @Input() tooltipEvent: string = 'hover';\n\n @Input() appendTo: any = 'body';\n\n @Input() positionStyle: string;\n\n @Input() tooltipStyleClass: string;\n\n @Input() tooltipZIndex: string = 'auto';\n\n @Input() escape: boolean = true;\n\n @Input() showDelay: number;\n\n @Input() hideDelay: number;\n\n @Input() life: number;\n\n @Input(\"tooltipDisabled\") get disabled(): boolean {\n return this._disabled;\n }\n set disabled(val:boolean) {\n this._disabled = val;\n this.deactivate();\n }\n\n _disabled: boolean;\n\n container: any;\n\n styleClass: string;\n\n tooltipText: any;\n\n showTimeout: any;\n\n hideTimeout: any;\n\n active: boolean;\n\n _text: string;\n\n mouseEnterListener: Function;\n\n mouseLeaveListener: Function;\n\n clickListener: Function;\n\n focusListener: Function;\n\n blurListener: Function;\n\n scrollHandler: any;\n\n resizeListener: any;\n\n constructor(public el: ElementRef, public zone: NgZone) { }\n\n ngAfterViewInit() {\n this.zone.runOutsideAngular(() => {\n if (this.tooltipEvent === 'hover') {\n this.mouseEnterListener = this.onMouseEnter.bind(this);\n this.mouseLeaveListener = this.onMouseLeave.bind(this);\n this.clickListener = this.onClick.bind(this);\n this.el.nativeElement.addEventListener('mouseenter', this.mouseEnterListener);\n this.el.nativeElement.addEventListener('mouseleave', this.mouseLeaveListener);\n this.el.nativeElement.addEventListener('click', this.clickListener);\n }\n else if (this.tooltipEvent === 'focus') {\n this.focusListener = this.onFocus.bind(this);\n this.blurListener = this.onBlur.bind(this);\n this.el.nativeElement.addEventListener('focus', this.focusListener);\n this.el.nativeElement.addEventListener('blur', this.blurListener);\n }\n });\n }\n\n onMouseEnter(e: Event) {\n if (!this.container && !this.showTimeout) {\n this.activate();\n }\n }\n\n onMouseLeave(e: Event) {\n this.deactivate();\n }\n\n onFocus(e: Event) {\n this.activate();\n }\n\n onBlur(e: Event) {\n this.deactivate();\n }\n\n onClick(e: Event) {\n this.deactivate();\n }\n\n activate() {\n this.active = true;\n this.clearHideTimeout();\n\n if (this.showDelay)\n this.showTimeout = setTimeout(() => { this.show() }, this.showDelay);\n else\n this.show();\n\n if (this.life) {\n let duration = this.showDelay ? this.life + this.showDelay : this.life;\n this.hideTimeout = setTimeout(() => { this.hide() }, duration);\n }\n }\n\n deactivate() {\n this.active = false;\n this.clearShowTimeout();\n\n if (this.hideDelay) {\n this.clearHideTimeout(); //life timeout\n this.hideTimeout = setTimeout(() => { this.hide() }, this.hideDelay);\n }\n else {\n this.hide();\n }\n }\n\n get text(): string {\n return this._text;\n }\n\n @Input('pTooltip') set text(text: string) {\n this._text = text;\n if (this.active) {\n if (this._text) {\n if (this.container && this.container.offsetParent) {\n this.updateText();\n\t\t\t\t\tthis.align();\n\t\t\t\t}\n else {\n this.show();\n }\n }\n else {\n this.hide();\n }\n }\n }\n\n create() {\n if (this.container) {\n this.clearHideTimeout();\n this.remove();\n }\n\n this.container = document.createElement('div');\n\n let tooltipArrow = document.createElement('div');\n tooltipArrow.className = 'p-tooltip-arrow';\n this.container.appendChild(tooltipArrow);\n\n this.tooltipText = document.createElement('div');\n this.tooltipText.className = 'p-tooltip-text';\n\n this.updateText();\n\n if (this.positionStyle) {\n this.container.style.position = this.positionStyle;\n }\n\n this.container.appendChild(this.tooltipText);\n\n if (this.appendTo === 'body')\n document.body.appendChild(this.container);\n else if (this.appendTo === 'target')\n DomHandler.appendChild(this.container, this.el.nativeElement);\n else\n DomHandler.appendChild(this.container, this.appendTo);\n\n this.container.style.display = 'inline-block';\n }\n\n show() {\n if (!this.text || this.disabled) {\n return;\n }\n\n this.create();\n this.align();\n DomHandler.fadeIn(this.container, 250);\n\n if (this.tooltipZIndex === 'auto')\n this.container.style.zIndex = ++DomHandler.zindex;\n else\n this.container.style.zIndex = this.tooltipZIndex;\n\n this.bindDocumentResizeListener();\n this.bindScrollListener();\n }\n\n hide() {\n this.remove();\n }\n\n updateText() {\n if (this.escape) {\n this.tooltipText.innerHTML = '';\n this.tooltipText.appendChild(document.createTextNode(this._text));\n }\n else {\n this.tooltipText.innerHTML = this._text;\n }\n }\n\n align() {\n let position = this.tooltipPosition;\n\n switch (position) {\n case 'top':\n this.alignTop();\n if (this.isOutOfBounds()) {\n this.alignBottom();\n if (this.isOutOfBounds()) {\n this.alignRight();\n\n if (this.isOutOfBounds()) {\n this.alignLeft();\n }\n }\n }\n break;\n\n case 'bottom':\n this.alignBottom();\n if (this.isOutOfBounds()) {\n this.alignTop();\n if (this.isOutOfBounds()) {\n this.alignRight();\n\n if (this.isOutOfBounds()) {\n this.alignLeft();\n }\n }\n }\n break;\n\n case 'left':\n this.alignLeft();\n if (this.isOutOfBounds()) {\n this.alignRight();\n\n if (this.isOutOfBounds()) {\n this.alignTop();\n\n if (this.isOutOfBounds()) {\n this.alignBottom();\n }\n }\n }\n break;\n\n case 'right':\n this.alignRight();\n if (this.isOutOfBounds()) {\n this.alignLeft();\n\n if (this.isOutOfBounds()) {\n this.alignTop();\n\n if (this.isOutOfBounds()) {\n this.alignBottom();\n }\n }\n }\n break;\n }\n }\n\n getHostOffset() {\n if (this.appendTo === 'body' || this.appendTo === 'target') {\n let offset = this.el.nativeElement.getBoundingClientRect();\n let targetLeft = offset.left + DomHandler.getWindowScrollLeft();\n let targetTop = offset.top + DomHandler.getWindowScrollTop();\n\n return { left: targetLeft, top: targetTop };\n }\n else {\n return { left: 0, top: 0 };\n }\n }\n\n alignRight() {\n this.preAlign('right');\n let hostOffset = this.getHostOffset();\n let left = hostOffset.left + DomHandler.getOuterWidth(this.el.nativeElement);\n let top = hostOffset.top + (DomHandler.getOuterHeight(this.el.nativeElement) - DomHandler.getOuterHeight(this.container)) / 2;\n this.container.style.left = left + 'px';\n this.container.style.top = top + 'px';\n }\n\n alignLeft() {\n this.preAlign('left');\n let hostOffset = this.getHostOffset();\n let left = hostOffset.left - DomHandler.getOuterWidth(this.container);\n let top = hostOffset.top + (DomHandler.getOuterHeight(this.el.nativeElement) - DomHandler.getOuterHeight(this.container)) / 2;\n this.container.style.left = left + 'px';\n this.container.style.top = top + 'px';\n }\n\n alignTop() {\n this.preAlign('top');\n let hostOffset = this.getHostOffset();\n let left = hostOffset.left + (DomHandler.getOuterWidth(this.el.nativeElement) - DomHandler.getOuterWidth(this.container)) / 2;\n let top = hostOffset.top - DomHandler.getOuterHeight(this.container);\n this.container.style.left = left + 'px';\n this.container.style.top = top + 'px';\n }\n\n alignBottom() {\n this.preAlign('bottom');\n let hostOffset = this.getHostOffset();\n let left = hostOffset.left + (DomHandler.getOuterWidth(this.el.nativeElement) - DomHandler.getOuterWidth(this.container)) / 2;\n let top = hostOffset.top + DomHandler.getOuterHeight(this.el.nativeElement);\n this.container.style.left = left + 'px';\n this.container.style.top = top + 'px';\n }\n\n preAlign(position: string) {\n this.container.style.left = -999 + 'px';\n this.container.style.top = -999 + 'px';\n\n let defaultClassName = 'p-tooltip p-component p-tooltip-' + position;\n this.container.className = this.tooltipStyleClass ? defaultClassName + ' ' + this.tooltipStyleClass : defaultClassName;\n }\n\n isOutOfBounds(): boolean {\n let offset = this.container.getBoundingClientRect();\n let targetTop = offset.top;\n let targetLeft = offset.left;\n let width = DomHandler.getOuterWidth(this.container);\n let height = DomHandler.getOuterHeight(this.container);\n let viewport = DomHandler.getViewport();\n\n return (targetLeft + width > viewport.width) || (targetLeft < 0) || (targetTop < 0) || (targetTop + height > viewport.height);\n }\n\n onWindowResize(e: Event) {\n this.hide();\n }\n\n bindDocumentResizeListener() {\n this.zone.runOutsideAngular(() => {\n this.resizeListener = this.onWindowResize.bind(this);\n window.addEventListener('resize', this.resizeListener);\n });\n }\n\n unbindDocumentResizeListener() {\n if (this.resizeListener) {\n window.removeEventListener('resize', this.resizeListener);\n this.resizeListener = null;\n }\n }\n\n bindScrollListener() {\n if (!this.scrollHandler) {\n this.scrollHandler = new ConnectedOverlayScrollHandler(this.el.nativeElement, () => {\n if (this.container) {\n this.hide();\n }\n });\n }\n\n this.scrollHandler.bindScrollListener();\n }\n\n unbindScrollListener() {\n if (this.scrollHandler) {\n this.scrollHandler.unbindScrollListener();\n }\n }\n\n unbindEvents() {\n if (this.tooltipEvent === 'hover') {\n this.el.nativeElement.removeEventListener('mouseenter', this.mouseEnterListener);\n this.el.nativeElement.removeEventListener('mouseleave', this.mouseLeaveListener);\n this.el.nativeElement.removeEventListener('click', this.clickListener);\n }\n else if (this.tooltipEvent === 'focus') {\n this.el.nativeElement.removeEventListener('focus', this.focusListener);\n this.el.nativeElement.removeEventListener('blur', this.blurListener);\n }\n\n this.unbindDocumentResizeListener();\n }\n\n remove() {\n if (this.container && this.container.parentElement) {\n if (this.appendTo === 'body')\n document.body.removeChild(this.container);\n else if (this.appendTo === 'target')\n this.el.nativeElement.removeChild(this.container);\n else\n DomHandler.removeChild(this.container, this.appendTo);\n }\n\n this.unbindDocumentResizeListener();\n this.unbindScrollListener();\n this.clearTimeouts();\n this.container = null;\n this.scrollHandler = null;\n }\n\n clearShowTimeout() {\n if (this.showTimeout) {\n clearTimeout(this.showTimeout);\n this.showTimeout = null;\n }\n }\n\n clearHideTimeout() {\n if (this.hideTimeout) {\n clearTimeout(this.hideTimeout);\n this.hideTimeout = null;\n }\n }\n\n clearTimeouts() {\n this.clearShowTimeout();\n this.clearHideTimeout();\n }\n\n ngOnDestroy() {\n this.unbindEvents();\n this.remove();\n\n if (this.scrollHandler) {\n this.scrollHandler.destroy();\n this.scrollHandler = null;\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Tooltip],\n declarations: [Tooltip]\n})\nexport class TooltipModule { }\n"]}