同步操作将从 Jason/mxgraph 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!--Copyright (c) 2006-2013, JGraph LtdHello, World! example for mxGraph. This example demonstrates creatingpermissions to define the available operations a the graph.--><html><head><title>Permissions example for mxGraph</title><!-- Sets the basepath for the library if not in same directory --><script type="text/javascript">mxBasePath = '../src';</script><!-- Loads and initializes the library --><script type="text/javascript" src="../src/js/mxClient.js"></script><!-- Example code --><script type="text/javascript">// Program starts here. Creates a sample graph in the// DOM node with the specified ID. This function is invoked// from the onLoad event handler of the document (see below).function main(){// Checks if the browser is supportedif (!mxClient.isBrowserSupported()){// Displays an error message if the browser is not supported.mxUtils.error('Browser is not supported!', 200, false);}else{// Defines an icon for creating new connections in the connection handler.// This will automatically disable the highlighting of the source vertex.mxConnectionHandler.prototype.connectImage = new mxImage('images/connector.gif', 16, 16);// Creates the div for the graphvar container = document.createElement('div');container.style.position = 'absolute';container.style.overflow = 'hidden';container.style.left = '00px';container.style.top = '40px';container.style.right = '0px';container.style.bottom = '0px';container.style.background = 'url("editors/images/grid.gif")';document.body.appendChild(container);// Workaround for Internet Explorer ignoring certain stylesif (mxClient.IS_QUIRKS){document.body.style.overflow = 'hidden';new mxDivResizer(container);}// Creates the graph inside the given containervar graph = new mxGraph(container);// Enable tooltips, disables mutligraphs, enable loopsgraph.setMultigraph(false);graph.setAllowLoops(true);// Enables rubberband selection and key handlingvar rubberband = new mxRubberband(graph);var keyHandler = new mxKeyHandler(graph);// Assigns the delete keykeyHandler.bindKey(46, function(evt){if (graph.isEnabled()){graph.removeCells();}});// Shared variable between child function scopes// aka "private" variablevar currentPermission = null;var apply = function(permission){graph.clearSelection();permission.apply(graph);graph.setEnabled(true);graph.setTooltips(true);// Updates the icons on the shapes - rarely// needed and very slow for large graphsgraph.refresh();currentPermission = permission;};apply(new Permission());var button = mxUtils.button('Allow All', function(evt){apply(new Permission());});document.body.appendChild(button);var button = mxUtils.button('Connect Only', function(evt){apply(new Permission(false, true, false, false, true));});document.body.appendChild(button);var button = mxUtils.button('Edges Only', function(evt){apply(new Permission(false, false, true, false, false));});document.body.appendChild(button);var button = mxUtils.button('Vertices Only', function(evt){apply(new Permission(false, false, false, true, false));});document.body.appendChild(button);var button = mxUtils.button('Select Only', function(evt){apply(new Permission(false, false, false, false, false));});document.body.appendChild(button);var button = mxUtils.button('Locked', function(evt){apply(new Permission(true, false));});document.body.appendChild(button);var button = mxUtils.button('Disabled', function(evt){graph.clearSelection();graph.setEnabled(false);graph.setTooltips(false);});document.body.appendChild(button);// Extends hook functions to use permission object. This could// be done by assigning the respective switches (eg.// setMovable), but this approach is more flexible, doesn't// override any existing behaviour or settings, and allows for// dynamic conditions to be used in the functions. See the// specification for more functions to extend (eg.// isSelectable).var oldDisconnectable = graph.isCellDisconnectable;graph.isCellDisconnectable = function(cell, terminal, source){return oldDisconnectable.apply(this, arguments) &¤tPermission.editEdges;};var oldTerminalPointMovable = graph.isTerminalPointMovable;graph.isTerminalPointMovable = function(cell){return oldTerminalPointMovable.apply(this, arguments) &¤tPermission.editEdges;};var oldBendable = graph.isCellBendable;graph.isCellBendable = function(cell){return oldBendable.apply(this, arguments) &¤tPermission.editEdges;};var oldLabelMovable = graph.isLabelMovable;graph.isLabelMovable = function(cell){return oldLabelMovable.apply(this, arguments) &¤tPermission.editEdges;};var oldMovable = graph.isCellMovable;graph.isCellMovable = function(cell){return oldMovable.apply(this, arguments) &¤tPermission.editVertices;};var oldResizable = graph.isCellResizable;graph.isCellResizable = function(cell){return oldResizable.apply(this, arguments) &¤tPermission.editVertices;};var oldEditable = graph.isCellEditable;graph.isCellEditable = function(cell){return oldEditable.apply(this, arguments) &&(this.getModel().isVertex(cell) &¤tPermission.editVertices) ||(this.getModel().isEdge(cell) &¤tPermission.editEdges);};var oldDeletable = graph.isCellDeletable;graph.isCellDeletable = function(cell){return oldDeletable.apply(this, arguments) &&(this.getModel().isVertex(cell) &¤tPermission.editVertices) ||(this.getModel().isEdge(cell) &¤tPermission.editEdges);};var oldCloneable = graph.isCellCloneable;graph.isCellCloneable = function(cell){return oldCloneable.apply(this, arguments) &¤tPermission.cloneCells;};// Gets the default parent for inserting new cells. This// is normally the first child of the root (ie. layer 0).var parent = graph.getDefaultParent();// Adds cells to the model in a single stepgraph.getModel().beginUpdate();try{var v1 = graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30);var v2 = graph.insertVertex(parent, null, 'Hello,', 200, 20, 80, 30);var v3 = graph.insertVertex(parent, null, 'World!', 200, 150, 80, 30);var e1 = graph.insertEdge(parent, null, 'Connection', v1, v3);}finally{// Updates the displaygraph.getModel().endUpdate();}}};function Permission(locked, createEdges, editEdges, editVertices, cloneCells){this.locked = (locked != null) ? locked : false;this.createEdges = (createEdges != null) ? createEdges : true;this.editEdges = (editEdges != null) ? editEdges : true;;this.editVertices = (editVertices != null) ? editVertices : true;;this.cloneCells = (cloneCells != null) ? cloneCells : true;;};Permission.prototype.apply = function(graph){graph.setConnectable(this.createEdges);graph.setCellsLocked(this.locked);};</script></head><!-- Page passes the container for the graph to the program --><body onload="main();"></body></html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。