source: trip-planner-front/node_modules/primeng/fesm2020/primeng-dragdrop.mjs

Last change on this file was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 10.2 KB
Line 
1import * as i0 from '@angular/core';
2import { EventEmitter, Directive, Input, Output, HostListener, NgModule } from '@angular/core';
3import { CommonModule } from '@angular/common';
4import { DomHandler } from 'primeng/dom';
5
6class Draggable {
7 constructor(el, zone) {
8 this.el = el;
9 this.zone = zone;
10 this.onDragStart = new EventEmitter();
11 this.onDragEnd = new EventEmitter();
12 this.onDrag = new EventEmitter();
13 }
14 get pDraggableDisabled() {
15 return this._pDraggableDisabled;
16 }
17 set pDraggableDisabled(_pDraggableDisabled) {
18 this._pDraggableDisabled = _pDraggableDisabled;
19 if (this._pDraggableDisabled) {
20 this.unbindMouseListeners();
21 }
22 else {
23 this.el.nativeElement.draggable = true;
24 this.bindMouseListeners();
25 }
26 }
27 ngAfterViewInit() {
28 if (!this.pDraggableDisabled) {
29 this.el.nativeElement.draggable = true;
30 this.bindMouseListeners();
31 }
32 }
33 bindDragListener() {
34 if (!this.dragListener) {
35 this.zone.runOutsideAngular(() => {
36 this.dragListener = this.drag.bind(this);
37 this.el.nativeElement.addEventListener('drag', this.dragListener);
38 });
39 }
40 }
41 unbindDragListener() {
42 if (this.dragListener) {
43 this.zone.runOutsideAngular(() => {
44 this.el.nativeElement.removeEventListener('drag', this.dragListener);
45 this.dragListener = null;
46 });
47 }
48 }
49 bindMouseListeners() {
50 if (!this.mouseDownListener && !this.mouseUpListener) {
51 this.zone.runOutsideAngular(() => {
52 this.mouseDownListener = this.mousedown.bind(this);
53 this.mouseUpListener = this.mouseup.bind(this);
54 this.el.nativeElement.addEventListener('mousedown', this.mouseDownListener);
55 this.el.nativeElement.addEventListener('mouseup', this.mouseUpListener);
56 });
57 }
58 }
59 unbindMouseListeners() {
60 if (this.mouseDownListener && this.mouseUpListener) {
61 this.zone.runOutsideAngular(() => {
62 this.el.nativeElement.removeEventListener('mousedown', this.mouseDownListener);
63 this.el.nativeElement.removeEventListener('mouseup', this.mouseUpListener);
64 this.mouseDownListener = null;
65 this.mouseUpListener = null;
66 });
67 }
68 }
69 drag(event) {
70 this.onDrag.emit(event);
71 }
72 dragStart(event) {
73 if (this.allowDrag() && !this.pDraggableDisabled) {
74 if (this.dragEffect) {
75 event.dataTransfer.effectAllowed = this.dragEffect;
76 }
77 event.dataTransfer.setData('text', this.scope);
78 this.onDragStart.emit(event);
79 this.bindDragListener();
80 }
81 else {
82 event.preventDefault();
83 }
84 }
85 dragEnd(event) {
86 this.onDragEnd.emit(event);
87 this.unbindDragListener();
88 }
89 mousedown(event) {
90 this.handle = event.target;
91 }
92 mouseup(event) {
93 this.handle = null;
94 }
95 allowDrag() {
96 if (this.dragHandle && this.handle)
97 return DomHandler.matches(this.handle, this.dragHandle);
98 else
99 return true;
100 }
101 ngOnDestroy() {
102 this.unbindDragListener();
103 this.unbindMouseListeners();
104 }
105}
106Draggable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Draggable, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
107Draggable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: Draggable, selector: "[pDraggable]", inputs: { scope: ["pDraggable", "scope"], dragEffect: "dragEffect", dragHandle: "dragHandle", pDraggableDisabled: "pDraggableDisabled" }, outputs: { onDragStart: "onDragStart", onDragEnd: "onDragEnd", onDrag: "onDrag" }, host: { listeners: { "dragstart": "dragStart($event)", "dragend": "dragEnd($event)" }, classAttribute: "p-element" }, ngImport: i0 });
108i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Draggable, decorators: [{
109 type: Directive,
110 args: [{
111 selector: '[pDraggable]',
112 host: {
113 'class': 'p-element'
114 }
115 }]
116 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { scope: [{
117 type: Input,
118 args: ['pDraggable']
119 }], dragEffect: [{
120 type: Input
121 }], dragHandle: [{
122 type: Input
123 }], onDragStart: [{
124 type: Output
125 }], onDragEnd: [{
126 type: Output
127 }], onDrag: [{
128 type: Output
129 }], pDraggableDisabled: [{
130 type: Input
131 }], dragStart: [{
132 type: HostListener,
133 args: ['dragstart', ['$event']]
134 }], dragEnd: [{
135 type: HostListener,
136 args: ['dragend', ['$event']]
137 }] } });
138class Droppable {
139 constructor(el, zone) {
140 this.el = el;
141 this.zone = zone;
142 this.onDragEnter = new EventEmitter();
143 this.onDragLeave = new EventEmitter();
144 this.onDrop = new EventEmitter();
145 }
146 ngAfterViewInit() {
147 if (!this.pDroppableDisabled) {
148 this.bindDragOverListener();
149 }
150 }
151 bindDragOverListener() {
152 if (!this.dragOverListener) {
153 this.zone.runOutsideAngular(() => {
154 this.dragOverListener = this.dragOver.bind(this);
155 this.el.nativeElement.addEventListener('dragover', this.dragOverListener);
156 });
157 }
158 }
159 unbindDragOverListener() {
160 if (this.dragOverListener) {
161 this.zone.runOutsideAngular(() => {
162 this.el.nativeElement.removeEventListener('dragover', this.dragOverListener);
163 this.dragOverListener = null;
164 });
165 }
166 }
167 dragOver(event) {
168 event.preventDefault();
169 }
170 drop(event) {
171 if (this.allowDrop(event)) {
172 DomHandler.removeClass(this.el.nativeElement, 'p-draggable-enter');
173 event.preventDefault();
174 this.onDrop.emit(event);
175 }
176 }
177 dragEnter(event) {
178 event.preventDefault();
179 if (this.dropEffect) {
180 event.dataTransfer.dropEffect = this.dropEffect;
181 }
182 DomHandler.addClass(this.el.nativeElement, 'p-draggable-enter');
183 this.onDragEnter.emit(event);
184 }
185 dragLeave(event) {
186 event.preventDefault();
187 DomHandler.removeClass(this.el.nativeElement, 'p-draggable-enter');
188 this.onDragLeave.emit(event);
189 }
190 allowDrop(event) {
191 let dragScope = event.dataTransfer.getData('text');
192 if (typeof (this.scope) == "string" && dragScope == this.scope) {
193 return true;
194 }
195 else if (this.scope instanceof Array) {
196 for (let j = 0; j < this.scope.length; j++) {
197 if (dragScope == this.scope[j]) {
198 return true;
199 }
200 }
201 }
202 return false;
203 }
204 ngOnDestroy() {
205 this.unbindDragOverListener();
206 }
207}
208Droppable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Droppable, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
209Droppable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: Droppable, selector: "[pDroppable]", inputs: { scope: ["pDroppable", "scope"], pDroppableDisabled: "pDroppableDisabled", dropEffect: "dropEffect" }, outputs: { onDragEnter: "onDragEnter", onDragLeave: "onDragLeave", onDrop: "onDrop" }, host: { listeners: { "drop": "drop($event)", "dragenter": "dragEnter($event)", "dragleave": "dragLeave($event)" }, classAttribute: "p-element" }, ngImport: i0 });
210i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Droppable, decorators: [{
211 type: Directive,
212 args: [{
213 selector: '[pDroppable]',
214 host: {
215 'class': 'p-element'
216 }
217 }]
218 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { scope: [{
219 type: Input,
220 args: ['pDroppable']
221 }], pDroppableDisabled: [{
222 type: Input
223 }], dropEffect: [{
224 type: Input
225 }], onDragEnter: [{
226 type: Output
227 }], onDragLeave: [{
228 type: Output
229 }], onDrop: [{
230 type: Output
231 }], drop: [{
232 type: HostListener,
233 args: ['drop', ['$event']]
234 }], dragEnter: [{
235 type: HostListener,
236 args: ['dragenter', ['$event']]
237 }], dragLeave: [{
238 type: HostListener,
239 args: ['dragleave', ['$event']]
240 }] } });
241class DragDropModule {
242}
243DragDropModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DragDropModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
244DragDropModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DragDropModule, declarations: [Draggable, Droppable], imports: [CommonModule], exports: [Draggable, Droppable] });
245DragDropModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DragDropModule, imports: [[CommonModule]] });
246i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: DragDropModule, decorators: [{
247 type: NgModule,
248 args: [{
249 imports: [CommonModule],
250 exports: [Draggable, Droppable],
251 declarations: [Draggable, Droppable]
252 }]
253 }] });
254
255/**
256 * Generated bundle index. Do not edit.
257 */
258
259export { DragDropModule, Draggable, Droppable };
Note: See TracBrowser for help on using the repository browser.