92 lines
13 KiB
JavaScript
92 lines
13 KiB
JavaScript
export class GridsterUtils {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
static merge(obj1, obj2, properties) {
|
|
for (const p in obj2) {
|
|
if (obj2[p] !== void 0 && properties.hasOwnProperty(p)) {
|
|
if (typeof obj2[p] === 'object') {
|
|
// create an empty object for the property if obj1 does not already have one.
|
|
if (!(p in obj1)) {
|
|
obj1[p] = {};
|
|
}
|
|
obj1[p] = GridsterUtils.merge(obj1[p], obj2[p], properties[p]);
|
|
}
|
|
else {
|
|
obj1[p] = obj2[p];
|
|
}
|
|
}
|
|
}
|
|
return obj1;
|
|
}
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
static checkTouchEvent(e) {
|
|
if (e.clientX === undefined && e.touches) {
|
|
if (e.touches && e.touches.length) {
|
|
e.clientX = e.touches[0].clientX;
|
|
e.clientY = e.touches[0].clientY;
|
|
}
|
|
else if (e.changedTouches && e.changedTouches.length) {
|
|
e.clientX = e.changedTouches[0].clientX;
|
|
e.clientY = e.changedTouches[0].clientY;
|
|
}
|
|
}
|
|
}
|
|
static checkContentClassForEvent(gridster, e) {
|
|
if (gridster.$options.draggable.ignoreContent) {
|
|
if (!GridsterUtils.checkDragHandleClass(e.target, e.currentTarget, gridster.$options.draggable.dragHandleClass, gridster.$options.draggable.ignoreContentClass)) {
|
|
return true;
|
|
}
|
|
}
|
|
else {
|
|
if (GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.ignoreContentClass)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
static checkContentClassForEmptyCellClickEvent(gridster, e) {
|
|
return (GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.ignoreContentClass) ||
|
|
GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.dragHandleClass));
|
|
}
|
|
static checkDragHandleClass(target, current, dragHandleClass, ignoreContentClass) {
|
|
if (!target || target === current) {
|
|
return false;
|
|
}
|
|
if (target.hasAttribute('class')) {
|
|
const classnames = target.getAttribute('class').split(' ');
|
|
if (classnames.indexOf(dragHandleClass) > -1) {
|
|
return true;
|
|
}
|
|
if (classnames.indexOf(ignoreContentClass) > -1) {
|
|
return false;
|
|
}
|
|
}
|
|
return GridsterUtils.checkDragHandleClass(target.parentNode, current, dragHandleClass, ignoreContentClass);
|
|
}
|
|
static checkContentClass(target, current, contentClass) {
|
|
if (!target || target === current) {
|
|
return false;
|
|
}
|
|
if (target.hasAttribute('class') &&
|
|
target.getAttribute('class').split(' ').indexOf(contentClass) > -1) {
|
|
return true;
|
|
}
|
|
else {
|
|
return GridsterUtils.checkContentClass(target.parentNode, current, contentClass);
|
|
}
|
|
}
|
|
static compareItems(a, b) {
|
|
if (a.y > b.y) {
|
|
return -1;
|
|
}
|
|
else if (a.y < b.y) {
|
|
return 1;
|
|
}
|
|
else if (a.x > b.x) {
|
|
return -1;
|
|
}
|
|
else {
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZHN0ZXJVdGlscy5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvYW5ndWxhci1ncmlkc3RlcjIvc3JjL2xpYi9ncmlkc3RlclV0aWxzLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsTUFBTSxPQUFPLGFBQWE7SUFDeEIsOERBQThEO0lBQzlELE1BQU0sQ0FBQyxLQUFLLENBQUMsSUFBUyxFQUFFLElBQVMsRUFBRSxVQUFlO1FBQ2hELEtBQUssTUFBTSxDQUFDLElBQUksSUFBSSxFQUFFO1lBQ3BCLElBQUksSUFBSSxDQUFDLENBQUMsQ0FBQyxLQUFLLEtBQUssQ0FBQyxJQUFJLFVBQVUsQ0FBQyxjQUFjLENBQUMsQ0FBQ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