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

View File

@ -473,62 +473,62 @@ class mxEdgeHandler {
* Creates and returns the <mxCellMarker> used in <marker>. * Creates and returns the <mxCellMarker> used in <marker>.
*/ */
createMarker = () => { createMarker = () => {
let marker = new mxCellMarker(this.graph);
let self = this; // closure let self = this; // closure
// Only returns edges if they are connectable and never returns class MyMarker extends mxCellMarker {
// the edge that is currently being modified // Only returns edges if they are connectable and never returns
marker.getCell = (me) => { // the edge that is currently being modified
let cell = getCell.apply(this, arguments); getCell = (me) => {
let cell = super.getCell(me);
// Checks for cell at preview point (with grid) // Checks for cell at preview point (with grid)
if ((cell === self.state.cell || cell == null) && self.currentPoint != null) { if ((cell === self.state.cell || cell == null) && self.currentPoint != null) {
cell = self.graph.getCellAt(self.currentPoint.x, self.currentPoint.y); 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 (this.graph.getModel().isVertex(parent) && this.graph.isCellConnectable(parent)) {
cell = parent;
} }
}
let model = self.graph.getModel(); // Uses connectable parent vertex if one exists
if (cell != null && !this.graph.isCellConnectable(cell)) {
let parent = this.graph.getModel().getParent(cell);
if ((this.graph.isSwimlane(cell) && self.currentPoint != null && if (this.graph.getModel().isVertex(parent) && this.graph.isCellConnectable(parent)) {
this.graph.hitsSwimlaneContent(cell, self.currentPoint.x, self.currentPoint.y)) || cell = parent;
(!self.isConnectableCell(cell)) || (cell === self.state.cell || }
(cell != null && !self.graph.connectableEdges && model.isEdge(cell))) || }
model.isAncestor(self.state.cell, cell)) {
cell = null;
}
if (!this.graph.isCellConnectable(cell)) { let model = self.graph.getModel();
cell = null;
}
return cell; if ((this.graph.isSwimlane(cell) && self.currentPoint != null &&
}; this.graph.hitsSwimlaneContent(cell, self.currentPoint.x, self.currentPoint.y)) ||
(!self.isConnectableCell(cell)) || (cell === self.state.cell ||
(cell != null && !self.graph.connectableEdges && model.isEdge(cell))) ||
model.isAncestor(self.state.cell, cell)) {
cell = null;
}
// Sets the highlight color according to validateConnection if (!this.graph.isCellConnectable(cell)) {
marker.isValidState = (state) => { cell = null;
let model = self.graph.getModel(); }
let other = self.graph.view.getTerminalPort(state, return cell;
self.graph.view.getState(model.getTerminal(self.state.cell, };
!self.isSource)), !self.isSource);
let otherCell = (other != null) ? other.cell : null;
let source = (self.isSource) ? state.cell : otherCell;
let target = (self.isSource) ? otherCell : state.cell;
// Updates the error message of the handler // Sets the highlight color according to validateConnection
self.error = self.validateConnection(source, target); isValidState = (state) => {
let model = self.graph.getModel();
let other = self.graph.view.getTerminalPort(state,
self.graph.view.getState(model.getTerminal(self.state.cell,
!self.isSource)), !self.isSource);
let otherCell = (other != null) ? other.cell : null;
let source = (self.isSource) ? state.cell : otherCell;
let target = (self.isSource) ? otherCell : state.cell;
return self.error == null; // Updates the error message of the handler
}; self.error = self.validateConnection(source, target);
return marker; return self.error == null;
};
}
return new MyMarker(this.graph);
}; };
/** /**