{"version":3,"sources":["../../src/app/components/lightbox/lightbox.ts"],"names":["Lightbox","el","renderer","cd","this","type","effectDuration","autoZIndex","baseZIndex","closeOnEscape","prototype","onImageClick","event","image","i","content","index","loading","style","width","height","preventDocumentClickListener","show","displayImage","preventDefault","ngAfterViewInit","panel","DomHandler","findSingle","nativeElement","appendTo","document","body","appendChild","onLinkClick","_this","setTimeout","markForCheck","currentImage","captionText","title","center","mask","createElement","addMultipleClasses","zindex","zIndex","visible","bindGlobalListeners","hide","removeChild","unbindGlobalListeners","elementWidth","getOuterWidth","elementHeight","getOuterHeight","visibility","display","onImageLoad","target","imageWidth","imageHeight","left","parseInt","top","fadeIn","prev","placeholder","images","next","length","documentTarget","ownerDocument","documentClickListener","listen","documentEscapeListener","which","Object","defineProperty","ngOnDestroy","Component","args","selector","template","changeDetection","ChangeDetectionStrategy","Default","encapsulation","ViewEncapsulation","None","ElementRef","Renderer2","ChangeDetectorRef","Input","NgModule","imports","CommonModule","exports","declarations"],"mappings":"2dAsFI,SAAAA,EAAmBC,EAAuBC,EAA4BC,GAAnDC,KAAAH,GAAAA,EAAuBG,KAAAF,SAAAA,EAA4BE,KAAAD,GAAAA,EAxC7DC,KAAAC,KAAe,QAUfD,KAAAE,eAAsB,QAEtBF,KAAAG,YAAsB,EAEtBH,KAAAI,WAAqB,EAErBJ,KAAAK,eAAyB,SA0BlCT,EAAAU,UAAAC,aAAA,SAAaC,EAAMC,EAAMC,EAAEC,GACvBX,KAAKY,MAAQF,EACbV,KAAKa,SAAU,EACfF,EAAQG,MAAMC,MAAQ,OACtBJ,EAAQG,MAAME,OAAS,OACvBhB,KAAKiB,8BAA+B,EACpCjB,KAAKkB,OACLlB,KAAKmB,aAAaV,GAClBD,EAAMY,kBAGVxB,EAAAU,UAAAe,gBAAA,WACIrB,KAAKsB,MAAQC,EAAAA,WAAWC,WAAWxB,KAAKH,GAAG4B,cAAe,iBAEtDzB,KAAK0B,WACiB,SAAlB1B,KAAK0B,SACLC,SAASC,KAA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A,kBAAkBC,u9dApCVC,EAAAA,kBAAiBC,EAAAA,iBAAkCC,EAAAA,qDA4CzEC,EAAAA,oBAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,wBAEAA,EAAAA,sBAEAA,EAAAA,8BAEAA,EAAAA,0BAEAA,EAAAA,0BAEAA,EAAAA,6BAEAA,EAAAA,eA0ML,iCALCC,EAAAA,SAAQb,KAAA,CAAC,CACNc,QAAS,CAACC,EAAAA,cACVC,QAAS,CAACjG,GACVkG,aAAc,CAAClG","sourcesContent":["import {NgModule,Component,ElementRef,Input,Renderer2,AfterViewInit,OnDestroy,ChangeDetectorRef,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\n\n@Component({\n selector: 'p-lightbox',\n template: `\n
\n \n \n \n
\n \n \n \n
\n
\n \n
\n \n \n
\n \n
\n
\n {{captionText}}\n
\n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.Default,\n encapsulation: ViewEncapsulation.None,\n styleUrls: [\n './lightbox.css',\n '../dialog/dialog.css'\n ]\n})\nexport class Lightbox implements AfterViewInit,OnDestroy {\n\n @Input() images: any[];\n \n @Input() type: string = 'image';\n\n @Input() style: any;\n \n @Input() styleClass: string;\n \n @Input() appendTo: any;\n \n @Input() easing: 'ease-out';\n \n @Input() effectDuration: any = '500ms';\n\n @Input() autoZIndex: boolean = true;\n \n @Input() baseZIndex: number = 0;\n \n @Input() closeOnEscape: boolean = true;\n\n public visible: boolean;\n \n public loading: boolean;\n \n public currentImage: any;\n \n public captionText: string;\n \n public zindex: any;\n \n public panel: any;\n \n public index: number;\n \n public mask: any;\n \n public preventDocumentClickListener: boolean;\n \n public documentClickListener: any;\n\n public documentEscapeListener: any;\n\n constructor(public el: ElementRef, public renderer: Renderer2,private cd: ChangeDetectorRef) {}\n \n onImageClick(event,image,i,content) {\n this.index = i;\n this.loading = true;\n content.style.width = 32 + 'px';\n content.style.height = 32 + 'px';\n this.preventDocumentClickListener = true;\n this.show();\n this.displayImage(image);\n event.preventDefault();\n }\n \n ngAfterViewInit() {\n this.panel = DomHandler.findSingle(this.el.nativeElement, '.ui-lightbox ');\n \n if (this.appendTo) {\n if (this.appendTo === 'body')\n document.body.appendChild(this.panel);\n else\n DomHandler.appendChild(this.panel, this.appendTo);\n }\n }\n \n onLinkClick(event,content) {\n this.preventDocumentClickListener = true;\n this.show();\n event.preventDefault();\n }\n \n displayImage(image) {\n setTimeout(() => {\n this.cd.markForCheck();\n this.currentImage = image;\n this.captionText = image.title;\n this.center();\n }, 1000);\n }\n \n show() {\n this.mask = document.createElement('div');\n \n DomHandler.addMultipleClasses(this.mask, 'ui-widget-overlay ui-dialog-mask');\n document.body.appendChild(this.mask);\n if (this.autoZIndex) {\n this.zindex = this.baseZIndex + (++DomHandler.zindex);\n }\n this.mask.style.zIndex = this.zindex - 1;\n this.center();\n this.visible = true;\n this.bindGlobalListeners();\n }\n \n hide(event) {\n this.captionText = null;\n this.index = null;\n this.currentImage = null;\n this.visible = false;\n \n if (this.mask) {\n document.body.removeChild(this.mask);\n this.mask = null;\n }\n \n this.unbindGlobalListeners();\n event.preventDefault();\n }\n \n center() {\n let elementWidth = DomHandler.getOuterWidth(this.panel);\n let elementHeight = DomHandler.getOuterHeight(this.panel);\n if (elementWidth == 0 && elementHeight == 0) {\n this.panel.style.visibility = 'hidden';\n this.panel.style.display = 'block';\n elementWidth = DomHandler.getOuterWidth(this.panel);\n elementHeight = DomHandler.getOuterHeight(this.panel);\n this.panel.style.display = 'none';\n this.panel.style.visibility = 'visible';\n }\n }\n \n onImageLoad(event,content) {\n let image = event.target;\n image.style.visibility = 'hidden';\n image.style.display = 'block';\n let imageWidth = DomHandler.getOuterWidth(image);\n let imageHeight = DomHandler.getOuterHeight(image);\n image.style.display = 'none';\n image.style.visibility = 'visible';\n\n content.style.width = imageWidth + 'px';\n content.style.height = imageHeight + 'px';\n this.panel.style.left = parseInt(this.panel.style.left) + (DomHandler.getOuterWidth(this.panel) - imageWidth) / 2 + 'px';\n this.panel.style.top = parseInt(this.panel.style.top) + (DomHandler.getOuterHeight(this.panel) - imageHeight) / 2 + 'px';\n\n setTimeout(() => {\n this.cd.markForCheck();\n DomHandler.fadeIn(image, 500);\n image.style.display = 'block';\n //this.captionText = this.currentImage.title;\n this.loading = false;\n }, parseInt(this.effectDuration));\n }\n \n prev(placeholder: any) {\n this.captionText = null;\n this.loading = true;\n placeholder.style.display = 'none';\n if (this.index > 0) {\n this.displayImage(this.images[--this.index]);\n }\n }\n \n next(placeholder: any) {\n this.captionText = null;\n this.loading = true;\n placeholder.style.display = 'none';\n if (this.index <= (this.images.length - 1)) {\n this.displayImage(this.images[++this.index]);\n }\n }\n\n bindGlobalListeners() {\n const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';\n\n this.documentClickListener = this.renderer.listen(documentTarget, 'click', (event) => {\n if (!this.preventDocumentClickListener && this.visible) {\n this.hide(event);\n }\n this.preventDocumentClickListener = false;\n this.cd.markForCheck();\n });\n if (this.closeOnEscape && !this.documentEscapeListener) {\n this.documentEscapeListener = this.renderer.listen(documentTarget, 'keydown', (event) => {\n if (event.which == 27) {\n if (parseInt(this.panel.style.zIndex) === (DomHandler.zindex + this.baseZIndex)) {\n this.hide(event);\n }\n }\n });\n }\n }\n\n unbindGlobalListeners() {\n if (this.documentEscapeListener){\n this.documentEscapeListener();\n this.documentEscapeListener = null;\n }\n\n if (this.documentClickListener) {\n this.documentClickListener();\n this.documentClickListener = null;\n }\n }\n \n get leftVisible():boolean {\n return this.images && this.images.length && this.index != 0 && !this.loading; \n }\n \n get rightVisible():boolean {\n return this.images && this.images.length && this.index < (this.images.length - 1) && !this.loading; \n }\n \n ngOnDestroy() {\n this.unbindGlobalListeners();\n \n if (this.appendTo) {\n this.el.nativeElement.appendChild(this.panel);\n }\n }\n \n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Lightbox],\n declarations: [Lightbox]\n})\nexport class LightboxModule { }\n"]}