updates to js syntax+added superclass calls to constructors

development
mcyph 2021-03-20 22:00:04 +11:00
parent 8ed2f25c20
commit b490313420
26 changed files with 116 additions and 87 deletions

View File

@ -2,6 +2,8 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxResources from "../util/mxResources";
import mxUtils from "../util/mxUtils";
class mxDefaultPopupMenu {
/**

View File

@ -3,8 +3,10 @@
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxClient from "../mxClient";
import mxToolbar from "../util/mxToolbar";
import mxGeometry from "../model/mxGeometry";
import mxUtils from "../util/mxUtils";
class mxDefaultToolbar {
/**

View File

@ -3,13 +3,23 @@
* Copyright (c) 2006-2019, draw.io AG
*/
import mxDefaultPopupMenu from "FIXME";
import mxDefaultPopupMenu from "./mxDefaultPopupMenu";
import mxUndoManager from "../util/mxUndoManager";
import mxDefaultKeyHandler from "FIXME";
import mxDefaultKeyHandler from "./mxDefaultKeyHandler";
import mxEventSource from "../util/mxEventSource";
import mxResources from "../util/mxResources";
import mxClient from "../mxClient";
import mxDivResizer from "FIXME";
import mxCompactTreeLayout from "../layout/mxCompactTreeLayout";
import mxDefaultToolbar from "./mxDefaultToolbar";
import mxStackLayout from "../layout/mxStackLayout";
import mxEventObject from "../util/mxEventObject";
import mxUtils from "../util/mxUtils";
import mxCodec from "../io/mxCodec";
import mxWindow from "../util/mxWindow";
import mxForm from "../util/mxForm";
import mxOutline from "../view/mxOutline";
import mxCell from "../model/mxCell";
import mxGeometry from "../model/mxGeometry";
/**
* Installs the required language resources at class
@ -366,6 +376,8 @@ class mxEditor extends mxEventSource {
* config - Optional XML node that contains the configuration.
*/
constructor(config) {
super();
this.actions = [];
this.addActions();
@ -1557,7 +1569,7 @@ class mxEditor extends mxEventSource {
var layoutMgr = new mxLayoutManager(graph);
var self = this; // closure
layoutMgr.getLayout=(cell) {
layoutMgr.getLayout=(cell)=>{
var layout = null;
var model = self.graph.getModel();
@ -1653,7 +1665,7 @@ class mxEditor extends mxEventSource {
graph.getView().addListener(mxEvent.UNDO, listener);
// Keeps the selection state in sync
var undoHandler=(sender, evt) {
var undoHandler=(sender, evt)=>{
var changes = evt.getProperty('edit').changes;
graph.setSelectionCells(graph.getSelectionCellsForChanges(changes));
};
@ -1768,7 +1780,7 @@ class mxEditor extends mxEventSource {
this.swimlaneSpacing, 2 * gs, 2 * gs);
// Overrides isIgnored to only take into account swimlanes
layout.isVertexIgnored=(cell) {
layout.isVertexIgnored=(cell)=>{
return !layout.graph.isSwimlane(cell);
};
@ -2483,7 +2495,7 @@ class mxEditor extends mxEventSource {
// Workaround for ignored iframe height 100% in FF
if (mxClient.IS_NS) {
var handler=(sender) {
var handler=(sender)=>{
var h = wnd.div.offsetHeight;
frame.setAttribute('height', (h - 26) + 'px');
};

View File

@ -2,6 +2,9 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxEventSource from "../util/mxEventSource";
import mxUtils from "../util/mxUtils";
import mxEventObject from "../util/mxEventObject";
class mxPanningHandler extends mxEventSource {
/**
@ -135,7 +138,8 @@ class mxPanningHandler extends mxEventSource {
* <code>event</code> property contains the corresponding <mxMouseEvent>.
*/
constructor(graph) {
// super not called
super();
if (graph != null) {
this.graph = graph;
this.graph.addMouseListener(this);
@ -160,7 +164,7 @@ class mxPanningHandler extends mxEventSource {
if (this.isPinchEnabled()) {
var evt = eo.getProperty('event');
if (!mxEvent.isConsumed(evt) && evt.type == 'gesturestart') {
if (!mxEvent.isConsumed(evt) && evt.type === 'gesturestart') {
this.initialScale = this.graph.view.scale;
// Forces start of panning when pinch gesture starts
@ -168,7 +172,7 @@ class mxPanningHandler extends mxEventSource {
this.start(this.mouseDownEvent);
this.mouseDownEvent = null;
}
} else if (evt.type == 'gestureend' && this.initialScale != null) {
} else if (evt.type === 'gestureend' && this.initialScale != null) {
this.initialScale = null;
}

View File

@ -2,6 +2,7 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxPopupMenu from "../util/mxPopupMenu";
class mxPopupMenuHandler extends mxPopupMenu {
/**
@ -65,7 +66,8 @@ class mxPopupMenuHandler extends mxPopupMenu {
* Constructs an event handler that creates a <mxPopupMenu>.
*/
constructor(graph, factoryMethod) {
// super not called
//super();
if (graph != null) {
this.graph = graph;
this.factoryMethod = factoryMethod;

View File

@ -3,7 +3,7 @@
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxObjectCodec from "FIXME";
import mxObjectCodec from "./mxObjectCodec";
import mxChildChange from "FIXME";
import mxCodecRegistry from "./mxCodecRegistry";

View File

@ -4,6 +4,7 @@
*/
import mxUtils from "../util/mxUtils";
import mxCellPath from "../model/mxCellPath";
class mxCodec {
/**

View File

@ -2,6 +2,7 @@
* Copyright (c) 2006-2018, JGraph Ltd
* Copyright (c) 2006-2018, Gaudenz Alder
*/
import mxHierarchicalLayoutStage from "./mxHierarchicalLayoutStage";
class mxCoordinateAssignment extends mxHierarchicalLayoutStage {
/**
@ -202,7 +203,8 @@ class mxCoordinateAssignment extends mxHierarchicalLayoutStage {
*/
constructor(layout, intraCellSpacing, interRankCellSpacing,
orientation, initialX, parallelEdgeSpacing) {
// super not called
super();
this.layout = layout;
this.intraCellSpacing = intraCellSpacing;
this.interRankCellSpacing = interRankCellSpacing;

View File

@ -2,6 +2,7 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxHierarchicalLayoutStage from "./mxHierarchicalLayoutStage";
class mxMedianHybridCrossingReduction extends mxHierarchicalLayoutStage {
/**
@ -23,7 +24,8 @@ class mxMedianHybridCrossingReduction extends mxHierarchicalLayoutStage {
* initialX - the leftmost coordinate node placement starts at
*/
constructor(layout) {
// super not called
super();
this.layout = layout;
};

View File

@ -2,6 +2,7 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxHierarchicalLayoutStage from "./mxHierarchicalLayoutStage";
class mxMinimumCycleRemover extends mxHierarchicalLayoutStage {
/**
@ -22,7 +23,8 @@ class mxMinimumCycleRemover extends mxHierarchicalLayoutStage {
* Creates a cycle remover for the given internal model.
*/
constructor(layout) {
// constructor not called
super();
this.layout = layout;
};

View File

@ -2,6 +2,7 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxHierarchicalLayoutStage from "./mxHierarchicalLayoutStage";
class mxSwimlaneOrdering extends mxHierarchicalLayoutStage {
/**
@ -22,7 +23,8 @@ class mxSwimlaneOrdering extends mxHierarchicalLayoutStage {
* Creates a cycle remover for the given internal model.
*/
constructor(layout) {
// super not called
super();
this.layout = layout;
};

View File

@ -2,30 +2,10 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxGraphLayout from "./mxGraphLayout";
import mxObjectIdentity from "FIXME";
class mxFastOrganicLayout extends mxGraphLayout {
/**
* Class: mxFastOrganicLayout
*
* Extends <mxGraphLayout> to implement a fast organic layout algorithm.
* The vertices need to be connected for this layout to work, vertices
* with no connections are ignored.
*
* Example:
*
* (code)
* var layout = new mxFastOrganicLayout(graph);
* layout.execute(graph.getDefaultParent());
* (end)
*
* Constructor: mxCompactTreeLayout
*
* Constructs a new fast organic layout for the specified graph.
*/
constructor(graph) {
super(graph);
};
/**
* Variable: useInputOrigin
*
@ -188,6 +168,28 @@ class mxFastOrganicLayout extends mxGraphLayout {
*/
allowedToRun = true;
/**
* Class: mxFastOrganicLayout
*
* Extends <mxGraphLayout> to implement a fast organic layout algorithm.
* The vertices need to be connected for this layout to work, vertices
* with no connections are ignored.
*
* Example:
*
* (code)
* var layout = new mxFastOrganicLayout(graph);
* layout.execute(graph.getDefaultParent());
* (end)
*
* Constructor: mxCompactTreeLayout
*
* Constructs a new fast organic layout for the specified graph.
*/
constructor(graph) {
super(graph);
};
/**
* Function: isVertexIgnored
*
@ -199,7 +201,7 @@ class mxFastOrganicLayout extends mxGraphLayout {
* vertex - <mxCell> whose ignored state should be returned.
*/
isVertexIgnored = (vertex) => {
return isVertexIgnored.apply(this, arguments) ||
return super.isVertexIgnored(vertex) ||
this.graph.getConnections(vertex).length == 0;
};

View File

@ -2,9 +2,7 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
var mxCellPath =
{
var mxCellPath = {
/**
* Class: mxCellPath
*
@ -27,16 +25,13 @@ var mxCellPath =
*
* cell - Cell whose path should be returned.
*/
create: (cell)=>
{
create: (cell) => {
var result = '';
if (cell != null)
{
if (cell != null) {
var parent = cell.getParent();
while (parent != null)
{
while (parent != null) {
var index = parent.getIndex(cell);
result = index + mxCellPath.PATH_SEPARATOR + result;
@ -48,8 +43,7 @@ var mxCellPath =
// Removes trailing separator
var n = result.length;
if (n > 1)
{
if (n > 1) {
result = result.substring(0, n - 1);
}
@ -66,18 +60,13 @@ var mxCellPath =
*
* path - Path whose parent path should be returned.
*/
getParentPath: (path)=>
{
if (path != null)
{
getParentPath: (path) => {
if (path != null) {
var index = path.lastIndexOf(mxCellPath.PATH_SEPARATOR);
if (index >= 0)
{
if (index >= 0) {
return path.substring(0, index);
}
else if (path.length > 0)
{
} else if (path.length > 0) {
return '';
}
}
@ -96,16 +85,13 @@ var mxCellPath =
* root - Root cell of the path to be resolved.
* path - String that defines the path.
*/
resolve: (root, path)=>
{
resolve: (root, path) => {
var parent = root;
if (path != null)
{
if (path != null) {
var tokens = path.split(mxCellPath.PATH_SEPARATOR);
for (var i=0; i<tokens.length; i++)
{
for (var i = 0; i < tokens.length; i++) {
parent = parent.getChildAt(parseInt(tokens[i]));
}
}
@ -119,22 +105,16 @@ var mxCellPath =
* Compares the given cell paths and returns -1 if p1 is smaller, 0 if
* p1 is equal and 1 if p1 is greater than p2.
*/
compare: (p1, p2)=>
{
compare: (p1, p2) => {
var min = Math.min(p1.length, p2.length);
var comp = 0;
for (var i = 0; i < min; i++)
{
if (p1[i] != p2[i])
{
for (var i = 0; i < min; i++) {
if (p1[i] != p2[i]) {
if (p1[i].length == 0 ||
p2[i].length == 0)
{
p2[i].length == 0) {
comp = (p1[i] == p2[i]) ? 0 : ((p1[i] > p2[i]) ? 1 : -1);
}
else
{
} else {
var t1 = parseInt(p1[i]);
var t2 = parseInt(p2[i]);
@ -146,20 +126,17 @@ var mxCellPath =
}
// Compares path length if both paths are equal to this point
if (comp === 0)
{
if (comp === 0) {
var t1 = p1.length;
var t2 = p2.length;
if (t1 !== t2)
{
if (t1 !== t2) {
comp = (t1 > t2) ? 1 : -1;
}
}
return comp;
}
};
export default mxCellPath;

View File

@ -36,6 +36,7 @@ class mxAnimation extends mxEventSource {
* graph - Reference to the enclosing <mxGraph>.
*/
constructor(delay) {
super();
this.delay = (delay != null) ? delay : 20;
};

View File

@ -96,6 +96,8 @@ class mxAutoSaveManager extends mxEventSource {
* graph - Reference to the enclosing graph.
*/
constructor(graph) {
super();
// Notifies the manager of a change
this.changeHandler = mxUtils.bind(this, (sender, evt) => {
if (this.isEnabled()) {

View File

@ -34,6 +34,7 @@ class mxPopupMenu extends mxEventSource {
* Fires after the menu has been shown in <popup>.
*/
constructor(factoryMethod) {
super();
this.factoryMethod = factoryMethod;
if (factoryMethod != null) {

View File

@ -5,6 +5,7 @@
import mxUtils from "./mxUtils";
import mxConstants from "./mxConstants";
import mxAbstractCanvas2D from "./mxAbstractCanvas2D";
/**
* Capability check for DOM parser and checks if base tag is used.
@ -28,7 +29,6 @@ let mxSvgCanvas2useAbsoluteIds = !mxClient.IS_CHROMEAPP &&
!mxClient.IS_EDGE && document.getElementsByTagName('base').length > 0;
*/
*/
class mxSvgCanvas2D extends mxAbstractCanvas2D {
/**
* Variable: path
@ -1181,9 +1181,7 @@ class mxSvgCanvas2D extends mxAbstractCanvas2D {
/**
* Updates existing DOM nodes for text rendering.
*/
mxSvgCanvas2D
.
createCss = (w, h, align, valign, wrap, overflow, clip, bg, border, flex, block, s, callback) => {
static createCss = (w, h, align, valign, wrap, overflow, clip, bg, border, flex, block, s, callback) => {
var item = 'box-sizing: border-box; font-size: 0; text-align: ' + ((align == mxConstants.ALIGN_LEFT) ? 'left' :
((align == mxConstants.ALIGN_RIGHT) ? 'right' : 'center')) + '; ';
var pt = mxUtils.getAlignmentAsPoint(align, valign);

View File

@ -4,6 +4,7 @@
*/
import mxUtils from "./mxUtils";
import mxEvent from "./mxEvent";
import mxPoint from "./mxPoint";
import mxPopupMenu from "./mxPopupMenu";
import mxEventSource from "./mxEventSource";
@ -67,6 +68,7 @@ class mxToolbar extends mxEventSource {
* container - DOM node that contains the toolbar.
*/
constructor(container) {
super();
this.container = container;
};

View File

@ -3,6 +3,7 @@
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxEvent from "./mxEvent";
import mxEventObject from "./mxEventObject";
import mxEventSource from "./mxEventSource";
@ -98,6 +99,7 @@ class mxUndoManager extends mxEventSource {
* size is given, then a default size of 100 steps is used.
*/
constructor(size) {
super();
this.size = (size != null) ? size : 100;
this.clear();
};

View File

@ -265,6 +265,8 @@ class mxWindow extends mxEventSource {
* mxWindow.
*/
constructor(title, content, x, y, width, height, minimizable, movable, replaceNode, style) {
super();
if (content != null) {
minimizable = (minimizable != null) ? minimizable : true;
this.content = content;

View File

@ -3,7 +3,7 @@
* Copyright (c) 2006-2015, Gaudenz Alder
*/
import mxPoint from "FIXME";
import mxPoint from "../util/mxPoint";
import mxRectangle from "../util/mxRectangle";
class mxCellOverlay extends mxEventSource {
@ -117,7 +117,8 @@ class mxCellOverlay extends mxEventSource {
* (default).
*/
constructor(image, tooltip, align, verticalAlign, offset, cursor) {
// no super
super();
this.image = image;
this.tooltip = tooltip;
this.align = (align != null) ? align : this.align;

View File

@ -1487,6 +1487,8 @@ class mxGraph extends mxEventSource {
* stylesheet - Optional <mxStylesheet> to be used in the graph.
*/
constructor(container, model, renderHint, stylesheet) {
super();
// Initializes the variable in case the prototype has been
// modified to hold some listeners (which is possible because
// the createHandlers call is executed regardless of the

View File

@ -81,6 +81,8 @@ class mxGraphSelectionModel extends mxEventSource {
* graph - Reference to the enclosing <mxGraph>.
*/
constructor(graph) {
super();
this.graph = graph;
this.cells = [];
};

View File

@ -191,6 +191,8 @@ class mxGraphView extends mxEventSource {
* graph - Reference to the enclosing <mxGraph>.
*/
constructor(graph) {
super();
this.graph = graph;
this.translate = new mxPoint();
this.graphBounds = new mxRectangle();

View File

@ -81,6 +81,8 @@ class mxLayoutManager extends mxEventSource {
* graph - Reference to the enclosing graph.
*/
constructor(graph) {
super();
// Executes the layout before the changes are dispatched
this.undoHandler = (sender, evt) => {
if (this.isEnabled()) {

View File

@ -71,6 +71,8 @@ class mxSwimlaneManager extends mxEventSource {
* graph - Reference to the enclosing graph.
*/
constructor(graph, horizontal, addEnabled, resizeEnabled) {
super();
this.horizontal = (horizontal != null) ? horizontal : true;
this.addEnabled = (addEnabled != null) ? addEnabled : true;
this.resizeEnabled = (resizeEnabled != null) ? resizeEnabled : true;