removed references to `arguments` object in various files

development
mcyph 2021-03-21 16:01:26 +11:00
parent 452ba705ea
commit 1f778c7869
2 changed files with 115 additions and 112 deletions

View File

@ -538,87 +538,90 @@ class mxConnectionHandler extends mxEventSource {
* Creates and returns the <mxCellMarker> used in <marker>.
*/
createMarker = () => {
let marker = new mxCellMarker(this.graph);
marker.hotspotEnabled = true;
let self = this;
class MyCellMarker extends mxCellMarker {
hotspotEnabled = true;
// Overrides to return cell at location only if valid (so that
// there is no highlight for invalid cells)
marker.getCell = mxUtils.bind(this, (me) => {
let cell = getCell.apply(marker, arguments);
this.error = null;
getCell = (me) => {
let cell = super.getCell(me);
self.error = null;
// Checks for cell at preview point (with grid)
if (cell == null && this.currentPoint != null) {
cell = this.graph.getCellAt(this.currentPoint.x, this.currentPoint.y);
if (cell == null && self.currentPoint != null) {
cell = self.graph.getCellAt(self.currentPoint.x, self.currentPoint.y);
}
// Uses connectable parent vertex if one exists
if (cell != null && !this.graph.isCellConnectable(cell)) {
let parent = this.graph.getModel().getParent(cell);
if (cell != null && !self.graph.isCellConnectable(cell)) {
let parent = self.graph.getModel().getParent(cell);
if (this.graph.getModel().isVertex(parent) && this.graph.isCellConnectable(parent)) {
if (self.graph.getModel().isVertex(parent) && self.graph.isCellConnectable(parent)) {
cell = parent;
}
}
if ((this.graph.isSwimlane(cell) && this.currentPoint != null &&
this.graph.hitsSwimlaneContent(cell, this.currentPoint.x, this.currentPoint.y)) ||
!this.isConnectableCell(cell)) {
if ((self.graph.isSwimlane(cell) && self.currentPoint != null &&
self.graph.hitsSwimlaneContent(cell, self.currentPoint.x, self.currentPoint.y)) ||
!self.isConnectableCell(cell)) {
cell = null;
}
if (cell != null) {
if (this.isConnecting()) {
if (this.previous != null) {
this.error = this.validateConnection(this.previous.cell, cell);
if (self.isConnecting()) {
if (self.previous != null) {
self.error = self.validateConnection(self.previous.cell, cell);
if (this.error != null && this.error.length === 0) {
if (self.error != null && self.error.length === 0) {
cell = null;
// Enables create target inside groups
if (this.isCreateTarget(me.getEvent())) {
this.error = null;
if (self.isCreateTarget(me.getEvent())) {
self.error = null;
}
}
}
} else if (!this.isValidSource(cell, me)) {
} else if (!self.isValidSource(cell, me)) {
cell = null;
}
} else if (this.isConnecting() && !this.isCreateTarget(me.getEvent()) &&
!this.graph.allowDanglingEdges) {
this.error = '';
} else if (self.isConnecting() && !self.isCreateTarget(me.getEvent()) &&
!self.graph.allowDanglingEdges) {
self.error = '';
}
return cell;
});
};
// Sets the highlight color according to validateConnection
marker.isValidState = (state) => {
if (this.isConnecting()) {
return this.error == null;
isValidState = (state) => {
if (self.isConnecting()) {
return self.error == null;
} else {
return this.isValidState.apply(marker, arguments);
return super.isValidState(state);
}
};
// Overrides to use marker color only in highlight mode or for
// target selection
marker.getMarkerColor = mxUtils.bind(this, (evt, state, isValid) => {
return (this.connectImage == null || this.isConnecting()) ?
getMarkerColor = (evt, state, isValid) => {
return (self.connectImage == null || self.isConnecting()) ?
super.getMarkerColor(evt, state, isValid) :
null;
});
};
// Overrides to use hotspot only for source selection otherwise
// intersects always returns true when over a cell
marker.intersects = (state, evt) => {
if (this.connectImage != null || this.isConnecting()) {
intersects = (state, evt) => {
if (self.connectImage != null || self.isConnecting()) {
return true;
}
return super.intersects(state, evt);
};
}
return marker;
return new MyCellMarker(this.graph);
};
/**
@ -1883,7 +1886,7 @@ class mxConnectionHandler extends mxEventSource {
}
let clone = this.graph.cloneCell(source);
let geo = this.graph.getModel().getGeometry(clone);
geo = this.graph.getModel().getGeometry(clone);
if (geo != null) {
let t = this.graph.view.translate;

View File

@ -473,13 +473,13 @@ class mxEdgeHandler {
* Creates and returns the <mxCellMarker> used in <marker>.
*/
createMarker = () => {
let marker = new mxCellMarker(this.graph);
let self = this; // closure
class MyMarker extends mxCellMarker {
// Only returns edges if they are connectable and never returns
// the edge that is currently being modified
marker.getCell = (me) => {
let cell = getCell.apply(this, arguments);
getCell = (me) => {
let cell = super.getCell(me);
// Checks for cell at preview point (with grid)
if ((cell === self.state.cell || cell == null) && self.currentPoint != null) {
@ -508,12 +508,11 @@ class mxEdgeHandler {
if (!this.graph.isCellConnectable(cell)) {
cell = null;
}
return cell;
};
// Sets the highlight color according to validateConnection
marker.isValidState = (state) => {
isValidState = (state) => {
let model = self.graph.getModel();
let other = self.graph.view.getTerminalPort(state,
self.graph.view.getState(model.getTerminal(self.state.cell,
@ -527,8 +526,9 @@ class mxEdgeHandler {
return self.error == null;
};
}
return marker;
return new MyMarker(this.graph);
};
/**