UNPKG

12 kBSource Map (JSON)View Raw
1{"version":3,"sources":["ng://primeng/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","ElementRef","NgZone","__decorate","Input","Output","HostListener","Directive","selector","Droppable","onDragEnter","onDragLeave","onDrop","pDroppableDisabled","bindDragOverListener","dragOverListener","dragOver","unbindDragOverListener","drop","allowDrop","dragEnter","dropEffect","dragLeave","dragScope","getData","Array","j","length","DragDropModule","NgModule","imports","CommonModule","exports","declarations"],"mappings":"iwBAAAA,EAAA,WA+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,aA2H9C,OA7GaG,OAAAC,eAAIT,EAAAU,UAAA,qBAAkB,KAAtB,WACL,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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A,aAAa,YAAa,CAAC,0CAjEnBG,EAASN,EAAA,CAHrBI,EAAAA,UAAU,CACPC,SAAU,kBAEDC,mBAiGb,SAAAmB,KAA8B,OAAjBA,EAAczB,EAAA,CAL1B0B,EAAAA,SAAS,CACNC,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAC/E,EAAUwD,GACpBwB,aAAc,CAAChF,EAAUwD,MAEhBmB","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<any> = new EventEmitter();\n \n @Output() onDragEnd: EventEmitter<any> = new EventEmitter();\n \n @Output() onDrag: EventEmitter<any> = 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<any> = new EventEmitter();\n \n @Output() onDragLeave: EventEmitter<any> = new EventEmitter();\n \n @Output() onDrop: EventEmitter<any> = 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 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 this.onDragEnter.emit(event);\n }\n \n @HostListener('dragleave', ['$event']) \n dragLeave(event) {\n event.preventDefault();\n \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 { }"]}
\No newline at end of file