From aa12cea8b67e7ecdebd4ebea773c6086223ff2f3 Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Sun, 24 May 2015 16:38:34 +0200 Subject: [PATCH] Fixed #860, edit node mode now works as it should. --- dist/vis.js | 15 +++++++++------ docs/network/index.html | 8 ++++---- lib/network/Network.js | 3 ++- lib/network/modules/ManipulationSystem.js | 8 ++++---- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/dist/vis.js b/dist/vis.js index d8b6136a..a507c014 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -16528,8 +16528,11 @@ return /******/ (function(modules) { // webpackBootstrap Network.prototype.addNodeMode = function () { return this.manipulation.addNodeMode.apply(this.manipulation, arguments); }; + Network.prototype.editNode = function () { + return this.manipulation.editNode.apply(this.manipulation, arguments); + }; Network.prototype.editNodeMode = function () { - return this.manipulation.editNodeMode.apply(this.manipulation, arguments); + console.log('please use editNode instead of editNodeMode');return this.manipulation.editNode.apply(this.manipulation, arguments); }; Network.prototype.addEdgeMode = function () { return this.manipulation.addEdgeMode.apply(this.manipulation, arguments); @@ -26571,14 +26574,14 @@ return /******/ (function(modules) { // webpackBootstrap this._temporaryBindEvent('click', this._performAddNode.bind(this)); } }, { - key: 'editNodeMode', + key: 'editNode', /** * call the bound function to handle the editing of the node. The node has to be selected. * * @private */ - value: function editNodeMode() { + value: function editNode() { var _this2 = this; // when using the gui, enable edit mode if it wasnt already. @@ -26599,7 +26602,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.options.editNode.length === 2) { this.options.editNode(data, function (finalizedData) { - if (finalizedData !== null && finalizedData !== undefined && _this2.inMode === 'delete') { + if (finalizedData !== null && finalizedData !== undefined && _this2.inMode === 'editNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) { _this2.body.data.nodes.update(finalizedData); _this2.showManipulatorToolbar(); @@ -27005,9 +27008,9 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: '_createEditNodeButton', value: function _createEditNodeButton(locale) { - var button = this._createButton('editNodeMode', 'vis-button vis-edit', locale['editNode'] || this.options.locales['en']['editNode']); + var button = this._createButton('editNode', 'vis-button vis-edit', locale['editNode'] || this.options.locales['en']['editNode']); this.manipulationDiv.appendChild(button); - this._bindHammerToDiv(button, this.editNodeMode.bind(this)); + this._bindHammerToDiv(button, this.editNode.bind(this)); } }, { key: '_createEditEdgeButton', diff --git a/docs/network/index.html b/docs/network/index.html index 73c4c26e..b9b7cee1 100644 --- a/docs/network/index.html +++ b/docs/network/index.html @@ -681,12 +681,12 @@ var locales = { enabled to false. - - editNodeMode() + + editNode() - + Returns: none - Go into editNode mode. The explaination from addNodeMode applies here as well. + Edit the selected node. The explaination from addNodeMode applies here as well. addEdgeMode() diff --git a/lib/network/Network.js b/lib/network/Network.js index c8362aee..7cf529ce 100644 --- a/lib/network/Network.js +++ b/lib/network/Network.js @@ -442,7 +442,8 @@ Network.prototype.getSeed = function() {return this.layoutEngine.get Network.prototype.enableEditMode = function() {return this.manipulation.enableEditMode.apply(this.manipulation,arguments);}; Network.prototype.disableEditMode = function() {return this.manipulation.disableEditMode.apply(this.manipulation,arguments);}; Network.prototype.addNodeMode = function() {return this.manipulation.addNodeMode.apply(this.manipulation,arguments);}; -Network.prototype.editNodeMode = function() {return this.manipulation.editNodeMode.apply(this.manipulation,arguments);}; +Network.prototype.editNode = function() {return this.manipulation.editNode.apply(this.manipulation,arguments);}; +Network.prototype.editNodeMode = function() {console.log("please use editNode instead of editNodeMode"); return this.manipulation.editNode.apply(this.manipulation,arguments);}; Network.prototype.addEdgeMode = function() {return this.manipulation.addEdgeMode.apply(this.manipulation,arguments);}; Network.prototype.editEdgeMode = function() {return this.manipulation.editEdgeMode.apply(this.manipulation,arguments);}; Network.prototype.deleteSelected = function() {return this.manipulation.deleteSelected.apply(this.manipulation,arguments);}; diff --git a/lib/network/modules/ManipulationSystem.js b/lib/network/modules/ManipulationSystem.js index 2a86ba8b..7e45fc72 100644 --- a/lib/network/modules/ManipulationSystem.js +++ b/lib/network/modules/ManipulationSystem.js @@ -253,7 +253,7 @@ class ManipulationSystem { * * @private */ - editNodeMode() { + editNode() { // when using the gui, enable edit mode if it wasnt already. if (this.editMode !== true) { this.enableEditMode(); @@ -272,7 +272,7 @@ class ManipulationSystem { if (this.options.editNode.length === 2) { this.options.editNode(data, (finalizedData) => { - if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'delete') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) { + if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'editNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback) { this.body.data.nodes.update(finalizedData); this.showManipulatorToolbar(); } @@ -669,9 +669,9 @@ class ManipulationSystem { } _createEditNodeButton(locale) { - let button = this._createButton('editNodeMode', 'vis-button vis-edit', locale['editNode'] || this.options.locales['en']['editNode']); + let button = this._createButton('editNode', 'vis-button vis-edit', locale['editNode'] || this.options.locales['en']['editNode']); this.manipulationDiv.appendChild(button); - this._bindHammerToDiv(button, this.editNodeMode.bind(this)); + this._bindHammerToDiv(button, this.editNode.bind(this)); } _createEditEdgeButton(locale) {