This commit is contained in:
aqu415
2022-02-21 21:15:59 +08:00
parent f5b42e6f5f
commit 49b1f0d7d7
4 changed files with 61 additions and 36 deletions
+44 -34
View File
@@ -1373,7 +1373,7 @@
return this.mind.get_node(nodeid);
},
add_node: function (parent_node, nodeid, topic, data) {
add_node: function (parent_node, nodeid, topic, data, stop_invoke_event) {
if (this.get_editable()) {
var node = this.mind.add_node(parent_node, nodeid, topic, data);
if (!!node) {
@@ -1382,11 +1382,13 @@
this.view.show(false);
this.view.reset_node_custom_style(node);
this.expand_node(parent_node);
this.invoke_event_handle(jm.event_type.edit, {
evt: 'add_node',
data: [parent_node.id, nodeid, topic, data],
node: nodeid
});
if (!stop_invoke_event) {
this.invoke_event_handle(jm.event_type.edit, {
evt: 'add_node',
data: [node.parent.id, nodeid, topic, data],
node: nodeid
});
}
}
return node;
} else {
@@ -1395,7 +1397,7 @@
}
},
insert_node_before: function (node_before, nodeid, topic, data) {
insert_node_before: function (node_before, nodeid, topic, data, stop_invoke_event) {
if (this.get_editable()) {
var beforeid = jm.util.is_node(node_before) ? node_before.id : node_before;
var node = this.mind.insert_node_before(node_before, nodeid, topic, data);
@@ -1403,11 +1405,13 @@
this.view.add_node(node);
this.layout.layout();
this.view.show(false);
this.invoke_event_handle(jm.event_type.edit, {
evt: 'insert_node_before',
data: [beforeid, nodeid, topic, data],
node: nodeid
});
if (!stop_invoke_event) {
this.invoke_event_handle(jm.event_type.edit, {
evt: 'insert_node_before',
data: [beforeid, nodeid, topic, data],
node: nodeid
});
}
}
return node;
} else {
@@ -1416,7 +1420,7 @@
}
},
insert_node_after: function (node_after, nodeid, topic, data) {
insert_node_after: function (node_after, nodeid, topic, data, stop_invoke_event) {
if (this.get_editable()) {
var afterid = jm.util.is_node(node_after) ? node_after.id : node_after;
var node = this.mind.insert_node_after(node_after, nodeid, topic, data);
@@ -1424,11 +1428,13 @@
this.view.add_node(node);
this.layout.layout();
this.view.show(false);
this.invoke_event_handle(jm.event_type.edit, {
evt: 'insert_node_after',
data: [afterid, nodeid, topic, data],
node: nodeid
});
if (!stop_invoke_event) {
this.invoke_event_handle(jm.event_type.edit, {
evt: 'insert_node_after',
data: [afterid, nodeid, topic, data],
node: nodeid
});
}
}
return node;
} else {
@@ -1437,7 +1443,7 @@
}
},
remove_node: function (node) {
remove_node: function (node, stop_invoke_event) {
if (!jm.util.is_node(node)) {
var the_node = this.get_node(node);
if (!the_node) {
@@ -1461,7 +1467,9 @@
this.layout.layout();
this.view.show(false);
this.view.restore_location(parent_node);
this.invoke_event_handle(jm.event_type.edit, {evt: 'remove_node', data: [nodeid], node: parentid});
if (!stop_invoke_event) {
this.invoke_event_handle(jm.event_type.edit, {evt: 'remove_node', data: [nodeid], node: parentid});
}
return true;
} else {
logger.error('fail, this mind map is not editable');
@@ -1469,7 +1477,7 @@
}
},
update_node: function (nodeid, topic) {
update_node: function (nodeid, topic, stop_invoke_event) {
if (this.get_editable()) {
if (jm.util.text.is_empty(topic)) {
logger.warn('fail, topic can not be empty');
@@ -1484,7 +1492,6 @@
}
node.topic = topic;
this.auto_height_node_before_update(node)
this.view.update_node(node);
@@ -1493,12 +1500,13 @@
this.view.show(false);
this.invoke_event_handle(jm.event_type.edit, {
evt: 'update_node',
data: [nodeid, topic],
node: nodeid
});
if (!stop_invoke_event) {
this.invoke_event_handle(jm.event_type.edit, {
evt: 'update_node',
data: [nodeid, topic],
node: nodeid
});
}
}
} else {
logger.error('fail, this mind map is not editable');
@@ -1516,18 +1524,20 @@
}
},
move_node: function (nodeid, beforeid, parentid, direction) {
move_node: function (nodeid, beforeid, parentid, direction, stop_invoke_event) {
if (this.get_editable()) {
var node = this.mind.move_node(nodeid, beforeid, parentid, direction);
if (!!node) {
this.view.update_node(node);
this.layout.layout();
this.view.show(false);
this.invoke_event_handle(jm.event_type.edit, {
evt: 'move_node',
data: [nodeid, beforeid, parentid, direction],
node: nodeid
});
if (!stop_invoke_event) {
this.invoke_event_handle(jm.event_type.edit, {
evt: 'move_node',
data: [nodeid, beforeid, parentid, direction],
node: nodeid
});
}
}
} else {
logger.error('fail, this mind map is not editable');