{"version":3,"file":"primeng-lightbox.umd.js","sources":["../../src/app/components/lightbox/lightbox.ts","../../src/app/components/lightbox/primeng-lightbox.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["DomHandler","Component","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","Renderer2","ChangeDetectorRef","Input","NgModule","CommonModule"],"mappings":";;;;;;;QAsFI,kBAAmB,EAAc,EAAS,QAAmB,EAAS,EAAqB;YAAxE,OAAE,GAAF,EAAE,CA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