{"version":3,"sources":["../../src/app/components/dragdrop/dragdrop.ts"],"names":["Draggable","el","zone","this","onDragStart","EventEmitter","onDragEnd","onDrag","Object","defineProperty","prototype","_pDraggableDisabled","unbindMouseListeners","nativeElement","draggable","bindMouseListeners","ngAfterViewInit","pDraggableDisabled","bindDragListener","_this","dragListener","runOutsideAngular","drag","bind","addEventListener","unbindDragListener","removeEventListener","mouseDownListener","mouseUpListener","mousedown","mouseup","event","emit","dragStart","allowDrag","dragEffect","dataTransfer","effectAllowed","setData","scope","preventDefault","dragEnd","handle","target","dragHandle","DomHandler","matches","ngOnDestroy","Directive","args","selector","ElementRef","NgZone","Input","Output","HostListener","Droppable","onDragEnter","onDragLeave","onDrop","pDroppableDisabled","bindDragOverListener","dragOverListener","dragOver","unbindDragOverListener","drop","allowDrop","removeClass","dragEnter","dropEffect","addClass","dragLeave","dragScope","getData","Array","j","length","NgModule","imports","CommonModule","exports","declarations"],"mappings":"2dA+BI,SAAAA,EAAmBC,EAAuBC,GAAvBC,KAAAF,GAAAA,EAAuBE,KAAAD,KAAAA,EAhBhCC,KAAAC,YAAiC,IAAIC,EAAAA,aAErCF,KAAAG,UAA+B,IAAID,EAAAA,aAEnCF,KAAAI,OAA4B,IAAIF,EAAAA,oBAc1CG,OAAAC,eAAaT,EAAAU,UAAA,qBAAkB,KAA/B,WACI,OAAOP,KAAKQ,yBAEhB,SAAuBA,GACnBR,KAAKQ,oBAAsBA,EAEvBR,KAAKQ,oBACLR,KAAKS,wBAGLT,KAAKF,GAAGY,cAAcC,WAAY,EAClCX,KAAKY,uDAIbf,EAAAU,UAAAM,gBAAA,WACSb,KAAKc,qBACNd,KAAKF,GAAGY,cAAcC,WAAY,EAClCX,KAAKY,uBAIbf,EAAAU,UAAAQ,iBAAA,WAAA,IAAAC,EAAAhB,KACSA,KAAKiB,cACNjB,KAAKD,KAAKmB,mBAAkB,WACxBF,EAAKC,aAAeD,EAAKG,KAAKC,KAAKJ,GACnCA,EAAKlB,GAAGY,cAAc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AAYN,KAAA,CAAC,YAAa,CAAC,oBAiChC,iCALC4B,EAAAA,SAAQ5B,KAAA,CAAC,CACN6B,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAChF,EAAUwD,GACpByB,aAAc,CAACjF,EAAUwD","sourcesContent":["import {NgModule,Directive,OnDestroy,AfterViewInit,ElementRef,HostListener,Input,Output,EventEmitter,NgZone} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\n\n@Directive({\n selector: '[pDraggable]'\n})\nexport class Draggable implements AfterViewInit, OnDestroy {\n \n @Input('pDraggable') scope: string;\n \n @Input() dragEffect: string;\n \n @Input() dragHandle: string;\n \n @Output() onDragStart: EventEmitter = new EventEmitter();\n \n @Output() onDragEnd: EventEmitter = new EventEmitter();\n \n @Output() onDrag: EventEmitter = new EventEmitter();\n \n handle: any;\n\n dragListener: any;\n\n mouseDownListener: any;\n\n mouseUpListener: any;\n\n _pDraggableDisabled: boolean;\n \n constructor(public el: ElementRef, public zone: NgZone) {}\n\n @Input() get pDraggableDisabled(): boolean {\n return this._pDraggableDisabled;\n }\n set pDraggableDisabled(_pDraggableDisabled:boolean) {\n this._pDraggableDisabled = _pDraggableDisabled;\n \n if (this._pDraggableDisabled) {\n this.unbindMouseListeners();\n }\n else {\n this.el.nativeElement.draggable = true;\n this.bindMouseListeners();\n }\n }\n \n ngAfterViewInit() {\n if (!this.pDraggableDisabled) {\n this.el.nativeElement.draggable = true;\n this.bindMouseListeners();\n }\n }\n\n bindDragListener() {\n if (!this.dragListener) {\n this.zone.runOutsideAngular(() => {\n this.dragListener = this.drag.bind(this);\n this.el.nativeElement.addEventListener('drag', this.dragListener);\n });\n }\n }\n\n unbindDragListener() {\n if (this.dragListener) {\n this.zone.runOutsideAngular(() => {\n this.el.nativeElement.removeEventListener('drag', this.dragListener);\n this.dragListener = null;\n });\n }\n }\n\n bindMouseListeners() {\n if (!this.mouseDownListener && !this.mouseUpListener) {\n this.zone.runOutsideAngular(() => {\n this.mouseDownListener = this.mousedown.bind(this);\n this.mouseUpListener = this.mouseup.bind(this);\n this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener);\n this.el.nativeElement.addEventListener('mouseup', this.mouseUpListener);\n });\n }\n }\n\n unbindMouseListeners() {\n if (this.mouseDownListener && this.mouseUpListener) {\n this.zone.runOutsideAngular(() => {\n this.el.nativeElement.removeEventListener('mousedown', this.mouseDownListener);\n this.el.nativeElement.removeEventListener('mouseup', this.mouseUpListener);\n this.mouseDownListener = null;\n this.mouseUpListener = null;\n });\n }\n }\n\n drag(event) {\n this.onDrag.emit(event);\n }\n\n @HostListener('dragstart', ['$event']) \n dragStart(event) {\n if (this.allowDrag() && !this.pDraggableDisabled) {\n if (this.dragEffect) {\n event.dataTransfer.effectAllowed = this.dragEffect;\n }\n event.dataTransfer.setData('text', this.scope);\n \n this.onDragStart.emit(event);\n\n this.bindDragListener();\n }\n else {\n event.preventDefault();\n }\n }\n\n @HostListener('dragend', ['$event']) \n dragEnd(event) {\n this.onDragEnd.emit(event);\n this.unbindDragListener();\n }\n \n mousedown(event) {\n this.handle = event.target;\n }\n\n mouseup(event) {\n this.handle = null;\n }\n \n allowDrag() : boolean {\n if (this.dragHandle && this.handle)\n return DomHandler.matches(this.handle, this.dragHandle);\n else\n return true;\n }\n\n ngOnDestroy() {\n this.unbindDragListener();\n this.unbindMouseListeners();\n }\n \n}\n\n@Directive({\n selector: '[pDroppable]'\n})\nexport class Droppable implements AfterViewInit, OnDestroy {\n \n @Input('pDroppable') scope: string|string[];\n\n @Input() pDroppableDisabled: boolean;\n \n @Input() dropEffect: string;\n \n @Output() onDragEnter: EventEmitter = new EventEmitter();\n \n @Output() onDragLeave: EventEmitter = new EventEmitter();\n \n @Output() onDrop: EventEmitter = new EventEmitter();\n \n constructor(public el: ElementRef, public zone: NgZone) {}\n\n dragOverListener: any;\n\n ngAfterViewInit() {\n if (!this.pDroppableDisabled) {\n this.bindDragOverListener();\n }\n }\n\n bindDragOverListener() {\n if (!this.dragOverListener) {\n this.zone.runOutsideAngular(() => {\n this.dragOverListener = this.dragOver.bind(this);\n this.el.nativeElement.addEventListener('dragover', this.dragOverListener);\n });\n }\n }\n\n unbindDragOverListener() {\n if (this.dragOverListener) {\n this.zone.runOutsideAngular(() => {\n this.el.nativeElement.removeEventListener('dragover', this.dragOverListener);\n this.dragOverListener = null;\n });\n }\n }\n\n dragOver(event) {\n event.preventDefault();\n }\n \n @HostListener('drop', ['$event'])\n drop(event) {\n if (this.allowDrop(event)) {\n DomHandler.removeClass(this.el.nativeElement, 'p-draggable-enter');\n event.preventDefault();\n this.onDrop.emit(event);\n }\n }\n \n @HostListener('dragenter', ['$event']) \n dragEnter(event) {\n event.preventDefault();\n \n if (this.dropEffect) {\n event.dataTransfer.dropEffect = this.dropEffect;\n }\n \n DomHandler.addClass(this.el.nativeElement, 'p-draggable-enter');\n this.onDragEnter.emit(event);\n }\n \n @HostListener('dragleave', ['$event']) \n dragLeave(event) {\n event.preventDefault();\n \n DomHandler.removeClass(this.el.nativeElement, 'p-draggable-enter');\n this.onDragLeave.emit(event);\n }\n \n allowDrop(event): boolean {\n let dragScope = event.dataTransfer.getData('text');\n if (typeof (this.scope) == \"string\" && dragScope == this.scope) {\n return true;\n }\n else if (this.scope instanceof Array) {\n for(let j = 0; j < this.scope.length; j++) {\n if (dragScope == this.scope[j]) {\n return true;\n }\n }\n }\n return false;\n }\n\n ngOnDestroy() {\n this.unbindDragOverListener();\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Draggable,Droppable],\n declarations: [Draggable,Droppable]\n})\nexport class DragDropModule { }"]}