Icard/angular-clarity-master(work.../node_modules/angular-gridster2/esm2022/lib/gridsterEmptyCell.service.mjs

255 lines
40 KiB
JavaScript

import { GridsterUtils } from './gridsterUtils.service';
export class GridsterEmptyCell {
constructor(gridster) {
this.gridster = gridster;
this.emptyCellClickCb = (e) => {
if (!this.gridster ||
this.gridster.movingItem ||
GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
return;
}
const item = this.getValidItemFromEvent(e);
if (!item) {
return;
}
if (this.gridster.options.emptyCellClickCallback) {
this.gridster.options.emptyCellClickCallback(e, item);
}
this.gridster.cdRef.markForCheck();
};
this.emptyCellContextMenuCb = (e) => {
if (this.gridster.movingItem ||
GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
return;
}
e.preventDefault();
e.stopPropagation();
const item = this.getValidItemFromEvent(e);
if (!item) {
return;
}
if (this.gridster.options.emptyCellContextMenuCallback) {
this.gridster.options.emptyCellContextMenuCallback(e, item);
}
this.gridster.cdRef.markForCheck();
};
this.emptyCellDragDrop = (e) => {
const item = this.getValidItemFromEvent(e);
if (!item) {
return;
}
if (this.gridster.options.emptyCellDropCallback) {
this.gridster.options.emptyCellDropCallback(e, item);
}
this.gridster.cdRef.markForCheck();
};
this.emptyCellDragOver = (e) => {
e.preventDefault();
e.stopPropagation();
const item = this.getValidItemFromEvent(e);
if (item) {
if (e.dataTransfer) {
e.dataTransfer.dropEffect = 'move';
}
this.gridster.movingItem = item;
}
else {
if (e.dataTransfer) {
e.dataTransfer.dropEffect = 'none';
}
this.gridster.movingItem = null;
}
this.gridster.previewStyle();
};
this.emptyCellMouseDown = (e) => {
if (GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
return;
}
e.preventDefault();
e.stopPropagation();
const item = this.getValidItemFromEvent(e);
const leftMouseButtonCode = 1;
if (!item ||
(e.buttons !== leftMouseButtonCode && !(e instanceof TouchEvent))) {
return;
}
this.initialItem = item;
this.gridster.movingItem = item;
this.gridster.previewStyle();
this.gridster.zone.runOutsideAngular(() => {
this.removeWindowMousemoveListenerFn = this.gridster.renderer.listen('window', 'mousemove', this.emptyCellMouseMove);
this.removeWindowTouchmoveListenerFn = this.gridster.renderer.listen('window', 'touchmove', this.emptyCellMouseMove);
});
this.removeWindowMouseupListenerFn = this.gridster.renderer.listen('window', 'mouseup', this.emptyCellMouseUp);
this.removeWindowTouchendListenerFn = this.gridster.renderer.listen('window', 'touchend', this.emptyCellMouseUp);
};
this.emptyCellMouseMove = (e) => {
e.preventDefault();
e.stopPropagation();
const item = this.getValidItemFromEvent(e, this.initialItem);
if (!item) {
return;
}
this.gridster.movingItem = item;
this.gridster.previewStyle();
};
this.emptyCellMouseUp = (e) => {
this.removeWindowMousemoveListenerFn();
this.removeWindowTouchmoveListenerFn();
this.removeWindowMouseupListenerFn();
this.removeWindowTouchendListenerFn();
const item = this.getValidItemFromEvent(e, this.initialItem);
if (item) {
this.gridster.movingItem = item;
}
if (this.gridster.options.emptyCellDragCallback &&
this.gridster.movingItem) {
this.gridster.options.emptyCellDragCallback(e, this.gridster.movingItem);
}
setTimeout(() => {
this.initialItem = null;
if (this.gridster) {
this.gridster.movingItem = null;
this.gridster.previewStyle();
}
});
this.gridster.cdRef.markForCheck();
};
}
destroy() {
if (this.gridster.previewStyle) {
this.gridster.previewStyle();
}
this.gridster.movingItem = null;
this.initialItem = this.gridster = null;
if (this.removeDocumentDragendListenerFn) {
this.removeDocumentDragendListenerFn();
this.removeDocumentDragendListenerFn = null;
}
}
updateOptions() {
if (this.gridster.$options.enableEmptyCellClick &&
!this.removeEmptyCellClickListenerFn &&
this.gridster.options.emptyCellClickCallback) {
this.removeEmptyCellClickListenerFn = this.gridster.renderer.listen(this.gridster.el, 'click', this.emptyCellClickCb);
this.removeEmptyCellTouchendListenerFn = this.gridster.renderer.listen(this.gridster.el, 'touchend', this.emptyCellClickCb);
}
else if (!this.gridster.$options.enableEmptyCellClick &&
this.removeEmptyCellClickListenerFn &&
this.removeEmptyCellTouchendListenerFn) {
this.removeEmptyCellClickListenerFn();
this.removeEmptyCellTouchendListenerFn();
this.removeEmptyCellClickListenerFn = null;
this.removeEmptyCellTouchendListenerFn = null;
}
if (this.gridster.$options.enableEmptyCellContextMenu &&
!this.removeEmptyCellContextMenuListenerFn &&
this.gridster.options.emptyCellContextMenuCallback) {
this.removeEmptyCellContextMenuListenerFn = this.gridster.renderer.listen(this.gridster.el, 'contextmenu', this.emptyCellContextMenuCb);
}
else if (!this.gridster.$options.enableEmptyCellContextMenu &&
this.removeEmptyCellContextMenuListenerFn) {
this.removeEmptyCellContextMenuListenerFn();
this.removeEmptyCellContextMenuListenerFn = null;
}
if (this.gridster.$options.enableEmptyCellDrop &&
!this.removeEmptyCellDropListenerFn &&
this.gridster.options.emptyCellDropCallback) {
this.removeEmptyCellDropListenerFn = this.gridster.renderer.listen(this.gridster.el, 'drop', this.emptyCellDragDrop);
this.gridster.zone.runOutsideAngular(() => {
this.removeEmptyCellDragoverListenerFn = this.gridster.renderer.listen(this.gridster.el, 'dragover', this.emptyCellDragOver);
});
this.removeDocumentDragendListenerFn = this.gridster.renderer.listen('document', 'dragend', () => {
this.gridster.movingItem = null;
this.gridster.previewStyle();
});
}
else if (!this.gridster.$options.enableEmptyCellDrop &&
this.removeEmptyCellDropListenerFn &&
this.removeEmptyCellDragoverListenerFn &&
this.removeDocumentDragendListenerFn) {
this.removeEmptyCellDropListenerFn();
this.removeEmptyCellDragoverListenerFn();
this.removeDocumentDragendListenerFn();
this.removeEmptyCellDragoverListenerFn = null;
this.removeEmptyCellDropListenerFn = null;
this.removeDocumentDragendListenerFn = null;
}
if (this.gridster.$options.enableEmptyCellDrag &&
!this.removeEmptyCellMousedownListenerFn &&
this.gridster.options.emptyCellDragCallback) {
this.removeEmptyCellMousedownListenerFn = this.gridster.renderer.listen(this.gridster.el, 'mousedown', this.emptyCellMouseDown);
this.removeEmptyCellTouchstartListenerFn = this.gridster.renderer.listen(this.gridster.el, 'touchstart', this.emptyCellMouseDown);
}
else if (!this.gridster.$options.enableEmptyCellDrag &&
this.removeEmptyCellMousedownListenerFn &&
this.removeEmptyCellTouchstartListenerFn) {
this.removeEmptyCellMousedownListenerFn();
this.removeEmptyCellTouchstartListenerFn();
this.removeEmptyCellMousedownListenerFn = null;
this.removeEmptyCellTouchstartListenerFn = null;
}
}
getPixelsX(e, rect) {
const scale = this.gridster.options.scale;
if (scale) {
return ((e.clientX - rect.left) / scale +
this.gridster.el.scrollLeft -
this.gridster.gridRenderer.getLeftMargin());
}
return (e.clientX +
this.gridster.el.scrollLeft -
rect.left -
this.gridster.gridRenderer.getLeftMargin());
}
getPixelsY(e, rect) {
const scale = this.gridster.options.scale;
if (scale) {
return ((e.clientY - rect.top) / scale +
this.gridster.el.scrollTop -
this.gridster.gridRenderer.getTopMargin());
}
return (e.clientY +
this.gridster.el.scrollTop -
rect.top -
this.gridster.gridRenderer.getTopMargin());
}
getValidItemFromEvent(e, oldItem) {
e.preventDefault();
e.stopPropagation();
GridsterUtils.checkTouchEvent(e);
const rect = this.gridster.el.getBoundingClientRect();
const x = this.getPixelsX(e, rect);
const y = this.getPixelsY(e, rect);
const item = {
x: this.gridster.pixelsToPositionX(x, Math.floor, true),
y: this.gridster.pixelsToPositionY(y, Math.floor, true),
cols: this.gridster.$options.defaultItemCols,
rows: this.gridster.$options.defaultItemRows
};
if (oldItem) {
item.cols = Math.min(Math.abs(oldItem.x - item.x) + 1, this.gridster.$options.emptyCellDragMaxCols);
item.rows = Math.min(Math.abs(oldItem.y - item.y) + 1, this.gridster.$options.emptyCellDragMaxRows);
if (oldItem.x < item.x) {
item.x = oldItem.x;
}
else if (oldItem.x - item.x >
this.gridster.$options.emptyCellDragMaxCols - 1) {
item.x = this.gridster.movingItem ? this.gridster.movingItem.x : 0;
}
if (oldItem.y < item.y) {
item.y = oldItem.y;
}
else if (oldItem.y - item.y >
this.gridster.$options.emptyCellDragMaxRows - 1) {
item.y = this.gridster.movingItem ? this.gridster.movingItem.y : 0;
}
}
if (!this.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