{"version":3,"file":"primeng-dragdrop.umd.js","sources":["../../src/app/components/dragdrop/dragdrop.ts","../../src/app/components/dragdrop/primeng-dragdrop.ts"],"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 { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["EventEmitter","DomHandler","Directive","ElementRef","NgZone","Input","Output","HostListener","NgModule","CommonModule"],"mappings":";;;;;;;QA+BI,mBAAmB,EAAc,EAAS,IAAY;YAAnC,OAAE,GAAF,EAAE,CAAY;YAAS,SAAI,GAAJ,IAAI,CAAQ;YAhB5C,gBAAW,GAAsB,IAAIA,iBAAY,EAAE,CAAC;YAEpD,cAAS,GAAsB,I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