2009-06-07 20:59:43 +02:00
|
|
|
/*
|
2011-07-27 19:53:32 +02:00
|
|
|
* Copyright [2011] [wisemapping]
|
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mindplot.MindmapDesigner = new Class({
|
2011-09-07 03:12:11 +02:00
|
|
|
Extends: Events,
|
2011-07-27 19:53:32 +02:00
|
|
|
initialize: function(profile, divElement) {
|
|
|
|
$assert(profile, "profile must be defined");
|
|
|
|
$assert(profile.zoom, "zoom must be defined");
|
|
|
|
$assert(divElement, "divElement must be defined");
|
|
|
|
|
2011-08-03 22:52:39 +02:00
|
|
|
// Dispatcher manager ...
|
2011-08-05 03:12:53 +02:00
|
|
|
var commandContext = new mindplot.CommandContext(this);
|
2011-09-06 06:03:27 +02:00
|
|
|
this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
|
|
|
|
// this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
2011-08-05 03:12:53 +02:00
|
|
|
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
2011-09-07 03:12:11 +02:00
|
|
|
this.fireEvent("modelUpdate", event);
|
2011-08-05 03:12:53 +02:00
|
|
|
}.bind(this));
|
2011-09-07 03:12:11 +02:00
|
|
|
|
2011-08-05 03:12:53 +02:00
|
|
|
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
2011-08-25 04:41:39 +02:00
|
|
|
this._model = new mindplot.DesignerModel(profile);
|
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Init Screen manager..
|
2011-08-27 00:41:50 +02:00
|
|
|
var screenManager = new mindplot.ScreenManager(divElement);
|
|
|
|
this._workspace = new mindplot.Workspace(screenManager, this._model.getZoom());
|
2011-08-23 19:25:49 +02:00
|
|
|
this._readOnly = profile.readOnly ? true : false;
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
// Init layout managers ...
|
2011-07-28 02:01:54 +02:00
|
|
|
this._layoutManager = new mindplot.layout.OriginalLayoutManager(this);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-19 18:38:37 +02:00
|
|
|
// Register events
|
|
|
|
if (!profile.readOnly) {
|
|
|
|
this._registerEvents();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_registerEvents : function() {
|
|
|
|
// Register mouse events ...
|
|
|
|
this._registerMouseEvents();
|
|
|
|
|
|
|
|
// Register keyboard events ...
|
2011-08-20 15:50:48 +02:00
|
|
|
mindplot.DesignerKeyboard.register(this);
|
2011-08-19 18:38:37 +02:00
|
|
|
|
|
|
|
// To prevent the user from leaving the page with changes ...
|
2011-08-21 17:42:00 +02:00
|
|
|
$(window).addEvent('beforeunload', function () {
|
2011-08-19 18:38:37 +02:00
|
|
|
if (this.needsSave()) {
|
|
|
|
this.save(null, false)
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
_registerMouseEvents : function() {
|
|
|
|
var workspace = this._workspace;
|
|
|
|
var screenManager = workspace.getScreenManager();
|
|
|
|
|
|
|
|
// Initialize workspace event listeners.
|
2011-08-20 15:50:48 +02:00
|
|
|
screenManager.addEvent('update', function() {
|
|
|
|
// Topic must be set to his original state. All editors must be closed.
|
2011-08-25 04:41:39 +02:00
|
|
|
var objects = this.getModel().getObjects();
|
2011-08-20 15:50:48 +02:00
|
|
|
objects.forEach(function(object) {
|
|
|
|
object.closeEditors();
|
|
|
|
});
|
|
|
|
|
2011-08-19 18:38:37 +02:00
|
|
|
// Clean some selected nodes on event ..
|
2011-08-27 00:41:50 +02:00
|
|
|
if (this._cleanScreen)
|
|
|
|
this._cleanScreen();
|
2011-08-19 18:38:37 +02:00
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
// Deselect on click ...
|
|
|
|
screenManager.addEvent('click', function(event) {
|
|
|
|
this.onObjectFocusEvent(null, event);
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
// Create nodes on double click...
|
|
|
|
screenManager.addEvent('dblclick', function(event) {
|
|
|
|
if (workspace.isWorkspaceEventsEnabled()) {
|
|
|
|
// Get mouse position
|
|
|
|
var pos = screenManager.getWorkspaceMousePosition(event);
|
|
|
|
|
|
|
|
// Create a new topic model ...
|
|
|
|
var mindmap = this.getMindmap();
|
|
|
|
var model = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE);
|
|
|
|
model.setPosition(pos.x, pos.y);
|
|
|
|
|
|
|
|
// Get central topic ...
|
2011-08-25 04:41:39 +02:00
|
|
|
var centralTopic = this.getModel().getCentralTopic();
|
2011-08-19 18:38:37 +02:00
|
|
|
var centralTopicId = centralTopic.getId();
|
|
|
|
|
|
|
|
// Execute action ...
|
|
|
|
this._actionDispatcher.addTopic(model, centralTopicId, true);
|
|
|
|
}
|
|
|
|
}.bind(this));
|
2011-08-23 19:25:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
$(document).addEvent('mousewheel', function(event) {
|
|
|
|
if (event.wheel > 0) {
|
|
|
|
this.zoomIn(1.05);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.zoomOut(1.05);
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-27 00:41:50 +02:00
|
|
|
setViewPort : function(size) {
|
|
|
|
this._workspace.setViewPort(size);
|
2011-08-28 16:38:15 +02:00
|
|
|
var model = this.getModel();
|
|
|
|
this._workspace.setZoom(model.getZoom(), true);
|
2011-08-27 00:41:50 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
_buildNodeGraph : function(model) {
|
|
|
|
var workspace = this._workspace;
|
|
|
|
|
|
|
|
// Create node graph ...
|
|
|
|
var topic = mindplot.NodeGraph.create(model);
|
|
|
|
this._layoutManager.addHelpers(topic);
|
|
|
|
|
|
|
|
// Append it to the workspace ...
|
2011-08-25 04:41:39 +02:00
|
|
|
this.getModel().addTopic(topic);
|
2011-08-20 15:50:48 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Add Topic events ...
|
2011-08-20 15:50:48 +02:00
|
|
|
if (!this._readOnly) {
|
|
|
|
// Add drag behaviour ...
|
|
|
|
this._layoutManager.registerListenersOnNode(topic);
|
|
|
|
|
|
|
|
// If a node had gained focus, clean the rest of the nodes ...
|
2011-08-21 17:42:00 +02:00
|
|
|
topic.addEvent('mousedown', function(event) {
|
2011-08-20 15:50:48 +02:00
|
|
|
this.onObjectFocusEvent(topic, event);
|
|
|
|
}.bind(this));
|
|
|
|
}
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
// Connect Topic ...
|
|
|
|
var isConnected = model.isConnected();
|
|
|
|
if (isConnected) {
|
|
|
|
// Improve this ...
|
|
|
|
var targetTopicModel = model.getParent();
|
|
|
|
var targetTopic = null;
|
|
|
|
|
2011-09-06 06:03:27 +02:00
|
|
|
var topics = this.getModel().getTopics();
|
2011-07-27 19:53:32 +02:00
|
|
|
for (var i = 0; i < topics.length; i++) {
|
|
|
|
var t = topics[i];
|
|
|
|
if (t.getModel() == targetTopicModel) {
|
|
|
|
targetTopic = t;
|
|
|
|
// Disconnect the node. It will be connected again later ...
|
|
|
|
model.disconnect();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$assert(targetTopic, "Could not find a topic to connect");
|
|
|
|
topic.connectTo(targetTopic, workspace);
|
2009-06-07 20:59:43 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
return topic;
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
onObjectFocusEvent : function(currentObject, event) {
|
2011-08-20 15:50:48 +02:00
|
|
|
// Close node editors ..
|
2011-08-25 04:41:39 +02:00
|
|
|
var topics = this.getModel().getTopics();
|
2011-08-20 15:50:48 +02:00
|
|
|
topics.forEach(function(topic) {
|
|
|
|
topic.closeEditors();
|
|
|
|
});
|
2011-08-05 06:06:56 +02:00
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
var model = this.getModel();
|
|
|
|
var objects = model.getObjects();
|
2011-08-20 15:50:48 +02:00
|
|
|
objects.forEach(function(object) {
|
|
|
|
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
|
|
|
if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) {
|
2011-08-19 18:38:37 +02:00
|
|
|
if (object.isOnFocus() && object != currentObject) {
|
|
|
|
object.setOnFocus(false);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-19 18:38:37 +02:00
|
|
|
selectAll : function() {
|
2011-08-25 04:41:39 +02:00
|
|
|
var model = this.getModel();
|
|
|
|
var objects = model.getObjects();
|
2011-08-19 18:38:37 +02:00
|
|
|
objects.forEach(function(object) {
|
|
|
|
object.setOnFocus(true);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
deselectAll : function() {
|
2011-08-25 04:41:39 +02:00
|
|
|
var objects = this.getModel().getObjects();
|
2011-08-19 18:38:37 +02:00
|
|
|
objects.forEach(function(object) {
|
|
|
|
object.setOnFocus(false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2011-08-25 05:01:17 +02:00
|
|
|
zoomOut : function(factor) {
|
|
|
|
if (!factor)
|
|
|
|
factor = 1.2;
|
|
|
|
|
|
|
|
var model = this.getModel();
|
|
|
|
var scale = model.getZoom() * factor;
|
|
|
|
if (scale <= 1.9) {
|
|
|
|
model.setZoom(scale);
|
|
|
|
this._workspace.setZoom(scale);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2011-08-23 19:25:49 +02:00
|
|
|
zoomIn : function(factor) {
|
|
|
|
if (!factor)
|
|
|
|
factor = 1.2;
|
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
var model = this.getModel();
|
|
|
|
var scale = model.getZoom() / factor;
|
2011-08-25 05:01:17 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
if (scale >= 0.3) {
|
2011-08-25 04:41:39 +02:00
|
|
|
model.setZoom(scale);
|
2011-08-25 05:01:17 +02:00
|
|
|
this._workspace.setZoom(scale);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
|
|
|
}
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
getModel : function() {
|
|
|
|
return this._model;
|
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
createChildForSelectedNode : function() {
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
var nodes = this.getModel().filterSelectedTopics();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (nodes.length <= 0) {
|
|
|
|
// If there are more than one node selected,
|
|
|
|
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
|
|
|
return;
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
|
|
|
if (nodes.length > 1) {
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// If there are more than one node selected,
|
|
|
|
core.Monitor.getInstance().logMessage('Could not create a topic. One topic must be selected.');
|
|
|
|
return;
|
|
|
|
}
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Add new node ...
|
|
|
|
var centalTopic = nodes[0];
|
|
|
|
var parentTopicId = centalTopic.getId();
|
|
|
|
var childModel = centalTopic.createChildModel(this._layoutManager.needsPrepositioning());
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-03 22:52:39 +02:00
|
|
|
// Execute event ...
|
|
|
|
this._actionDispatcher.addTopic(childModel, parentTopicId, true);
|
|
|
|
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
createSiblingForSelectedNode : function() {
|
2011-08-25 04:41:39 +02:00
|
|
|
var nodes = this.getModel().filterSelectedTopics();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (nodes.length <= 0) {
|
|
|
|
// If there are more than one node selected,
|
|
|
|
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
|
|
|
return;
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
|
|
|
if (nodes.length > 1) {
|
|
|
|
// If there are more than one node selected,
|
|
|
|
core.Monitor.getInstance().logMessage('Could not create a topic. One topic must be selected.');
|
|
|
|
return;
|
|
|
|
}
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
var topic = nodes[0];
|
2011-08-08 00:27:23 +02:00
|
|
|
if (topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
2011-07-27 19:53:32 +02:00
|
|
|
// Central topic doesn't have siblings ...
|
|
|
|
this.createChildForSelectedNode();
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
} else {
|
|
|
|
var parentTopic = topic.getOutgoingConnectedTopic();
|
|
|
|
var siblingModel = topic.createSiblingModel(this._layoutManager.needsPrepositioning());
|
|
|
|
var parentTopicId = parentTopic.getId();
|
|
|
|
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.addTopic(siblingModel, parentTopicId, true);
|
2009-06-07 20:59:43 +02:00
|
|
|
}
|
2011-08-25 05:17:13 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
addRelationShip : function(event) {
|
2011-07-27 19:53:32 +02:00
|
|
|
var screen = this._workspace.getScreenManager();
|
|
|
|
var pos = screen.getWorkspaceMousePosition(event);
|
2011-08-25 04:41:39 +02:00
|
|
|
var selectedTopics = this.getModel().filterSelectedTopics();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (selectedTopics.length > 0 &&
|
|
|
|
(!$defined(this._creatingRelationship) || ($defined(this._creatingRelationship) && !this._creatingRelationship))) {
|
|
|
|
this._workspace.enableWorkspaceEvents(false);
|
|
|
|
var fromNodePosition = selectedTopics[0].getPosition();
|
|
|
|
this._relationship = new web2d.CurvedLine();
|
|
|
|
this._relationship.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
|
|
|
this._relationship.setDashed(2, 2);
|
|
|
|
this._relationship.setFrom(fromNodePosition.x, fromNodePosition.y);
|
|
|
|
this._relationship.setTo(pos.x, pos.y);
|
|
|
|
this._workspace.appendChild(this._relationship);
|
|
|
|
this._creatingRelationship = true;
|
|
|
|
this._relationshipMouseMoveFunction = this._relationshipMouseMove.bindWithEvent(this);
|
|
|
|
this._relationshipMouseClickFunction = this._relationshipMouseClick.bindWithEvent(this, selectedTopics[0]);
|
2011-08-13 17:33:37 +02:00
|
|
|
|
|
|
|
screen.addEvent('mousemove', this._relationshipMouseMoveFunction);
|
|
|
|
screen.addEvent('click', this._relationshipMouseClickFunction);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
_relationshipMouseMove : function(event) {
|
|
|
|
var screen = this._workspace.getScreenManager();
|
|
|
|
var pos = screen.getWorkspaceMousePosition(event);
|
|
|
|
this._relationship.setTo(pos.x - 1, pos.y - 1); //to prevent click event target to be the line itself
|
|
|
|
event.preventDefault();
|
|
|
|
event.stop();
|
|
|
|
return false;
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
_relationshipMouseClick : function (event, fromNode) {
|
|
|
|
var target = event.target;
|
|
|
|
while (target.tagName != "g" && $defined(target.parentNode)) {
|
|
|
|
target = target.parentNode;
|
|
|
|
}
|
|
|
|
if ($defined(target.virtualRef)) {
|
|
|
|
var targetNode = target.virtualRef;
|
|
|
|
this.addRelationship(fromNode, targetNode);
|
|
|
|
}
|
|
|
|
this._workspace.removeChild(this._relationship);
|
|
|
|
this._relationship = null;
|
2011-08-13 17:33:37 +02:00
|
|
|
this._workspace.getScreenManager().removeEvent('mousemove', this._relationshipMouseMoveFunction);
|
|
|
|
this._workspace.getScreenManager().removeEvent('click', this._relationshipMouseClickFunction);
|
2011-07-27 19:53:32 +02:00
|
|
|
this._creatingRelationship = false;
|
|
|
|
this._workspace.enableWorkspaceEvents(true);
|
|
|
|
event.preventDefault();
|
|
|
|
event.stop();
|
|
|
|
return false;
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
addRelationship : function(fromNode, toNode) {
|
|
|
|
// Create a new topic model ...
|
|
|
|
var mindmap = this.getMindmap();
|
|
|
|
var model = mindmap.createRelationship(fromNode.getModel().getId(), toNode.getModel().getId());
|
|
|
|
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.addRelationship(model, mindmap);
|
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
needsSave : function() {
|
|
|
|
return this._actionRunner.hasBeenChanged();
|
|
|
|
},
|
|
|
|
|
|
|
|
autoSaveEnabled : function(value) {
|
|
|
|
if ($defined(value) && value) {
|
|
|
|
var autosave = function() {
|
|
|
|
if (this.needsSave()) {
|
|
|
|
this.save(null, false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
autosave.bind(this).periodical(30000);
|
|
|
|
}
|
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
save : function(onSavedHandler, saveHistory) {
|
|
|
|
var persistantManager = mindplot.PersistanceManager;
|
|
|
|
var mindmap = this._mindmap;
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-25 05:01:17 +02:00
|
|
|
var properties = {zoom:this.getModel().getZoom(), layoutManager:this._layoutManager.getClassName()};
|
2011-07-27 19:53:32 +02:00
|
|
|
persistantManager.save(mindmap, properties, onSavedHandler, saveHistory);
|
2011-09-07 03:12:11 +02:00
|
|
|
this.fireEvent("save", {type:saveHistory});
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Refresh undo state...
|
|
|
|
this._actionRunner.markAsChangeBase();
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-09 07:27:59 +02:00
|
|
|
loadFromCollaborativeModel: function(collaborationManager) {
|
2011-08-08 00:27:23 +02:00
|
|
|
var mindmap = collaborationManager.buildWiseModel();
|
|
|
|
this._loadMap(1, mindmap);
|
|
|
|
|
|
|
|
// Place the focus on the Central Topic
|
2011-08-25 04:41:39 +02:00
|
|
|
var centralTopic = this.getModel().getCentralTopic();
|
2011-08-19 18:38:37 +02:00
|
|
|
this.goToNode.attempt(centralTopic, this);
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
2011-08-08 00:27:23 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
loadFromXML : function(mapId, xmlContent) {
|
|
|
|
$assert(xmlContent, 'mindmapId can not be null');
|
|
|
|
$assert(xmlContent, 'xmlContent can not be null');
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Explorer Hack with local files ...
|
|
|
|
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
|
|
|
var mindmap = serializer.loadFromDom(domDocument);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
this._loadMap(mapId, mindmap);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Place the focus on the Central Topic
|
2011-08-25 04:41:39 +02:00
|
|
|
var centralTopic = this.getModel().getCentralTopic();
|
2011-08-20 15:50:48 +02:00
|
|
|
this.goToNode(centralTopic);
|
2009-06-11 19:43:45 +02:00
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
load : function(mapId) {
|
|
|
|
$assert(mapId, 'mapName can not be null');
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Build load function ...
|
|
|
|
var persistantManager = mindplot.PersistanceManager;
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Loading mindmap ...
|
|
|
|
var mindmap = persistantManager.load(mapId);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Finally, load the map in the editor ...
|
|
|
|
this._loadMap(mapId, mindmap);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Place the focus on the Central Topic
|
2011-08-25 04:41:39 +02:00
|
|
|
var centralTopic = this.getModel().getCentralTopic();
|
2011-08-19 18:38:37 +02:00
|
|
|
this.goToNode.attempt(centralTopic, this);
|
2011-09-07 03:12:11 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
_loadMap : function(mapId, mindmapModel) {
|
|
|
|
var designer = this;
|
|
|
|
if (mindmapModel != null) {
|
|
|
|
mindmapModel.setId(mapId);
|
|
|
|
designer._mindmap = mindmapModel;
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Building node graph ...
|
|
|
|
var branches = mindmapModel.getBranches();
|
|
|
|
for (var i = 0; i < branches.length; i++) {
|
|
|
|
// NodeModel -> NodeGraph ...
|
|
|
|
var nodeModel = branches[i];
|
2011-08-05 06:06:56 +02:00
|
|
|
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Update shrink render state...
|
|
|
|
nodeGraph.setBranchVisibility(true);
|
|
|
|
}
|
|
|
|
var relationships = mindmapModel.getRelationships();
|
|
|
|
for (var j = 0; j < relationships.length; j++) {
|
2011-08-21 17:42:00 +02:00
|
|
|
this._relationshipModelToRelationship(relationships[j]);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
|
|
|
}
|
2011-08-25 04:41:39 +02:00
|
|
|
|
|
|
|
this.getModel().getTopics().forEach(function(topic) {
|
2011-07-27 19:53:32 +02:00
|
|
|
delete topic.getModel()._finalPosition;
|
|
|
|
});
|
2009-06-11 19:43:45 +02:00
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
getMindmap : function() {
|
|
|
|
return this._mindmap;
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
undo : function() {
|
|
|
|
this._actionRunner.undo();
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
redo : function() {
|
|
|
|
this._actionRunner.redo();
|
2011-08-25 04:41:39 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
_nodeModelToNodeGraph : function(nodeModel, isVisible) {
|
|
|
|
$assert(nodeModel, "Node model can not be null");
|
|
|
|
var nodeGraph = this._buildNodeGraph(nodeModel);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-05 06:06:56 +02:00
|
|
|
if (isVisible)
|
2011-07-27 19:53:32 +02:00
|
|
|
nodeGraph.setVisibility(isVisible);
|
2011-02-09 15:29:09 +01:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
var children = nodeModel.getChildren().slice();
|
|
|
|
children = this._layoutManager.prepareNode(nodeGraph, children);
|
2011-03-17 17:28:19 +01:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
for (var i = 0; i < children.length; i++) {
|
|
|
|
var child = children[i];
|
|
|
|
if ($defined(child))
|
2011-08-05 06:06:56 +02:00
|
|
|
this._nodeModelToNodeGraph(child, false);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
var workspace = this._workspace;
|
|
|
|
workspace.appendChild(nodeGraph);
|
|
|
|
return nodeGraph;
|
2011-08-05 06:06:56 +02:00
|
|
|
}
|
|
|
|
,
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
_relationshipModelToRelationship : function(model) {
|
|
|
|
$assert(model, "Node model can not be null");
|
|
|
|
var relationship = this._buildRelationship(model);
|
|
|
|
var sourceTopic = relationship.getSourceTopic();
|
|
|
|
sourceTopic.addRelationship(relationship);
|
|
|
|
var targetTopic = relationship.getTargetTopic();
|
|
|
|
targetTopic.addRelationship(relationship);
|
|
|
|
relationship.setVisibility(sourceTopic.isVisible() && targetTopic.isVisible());
|
|
|
|
var workspace = this._workspace;
|
|
|
|
workspace.appendChild(relationship);
|
|
|
|
relationship.redraw();
|
|
|
|
return relationship;
|
2011-08-19 18:38:37 +02:00
|
|
|
}
|
|
|
|
,
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
createRelationship : function(model) {
|
|
|
|
this._mindmap.addRelationship(model);
|
|
|
|
return this._relationshipModelToRelationship(model);
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
removeRelationship : function(model) {
|
|
|
|
this._mindmap.removeRelationship(model);
|
|
|
|
var relationship = this._relationships[model.getId()];
|
|
|
|
var sourceTopic = relationship.getSourceTopic();
|
|
|
|
sourceTopic.removeRelationship(relationship);
|
|
|
|
var targetTopic = relationship.getTargetTopic();
|
|
|
|
targetTopic.removeRelationship(relationship);
|
|
|
|
this._workspace.removeChild(relationship);
|
|
|
|
delete this._relationships[model.getId()];
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
_buildRelationship : function (topicModel) {
|
2011-07-27 19:53:32 +02:00
|
|
|
var elem = this;
|
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
var fromNodeId = topicModel.getFromNode();
|
|
|
|
var toNodeId = topicModel.getToNode();
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
var fromTopic = null;
|
|
|
|
var toTopic = null;
|
2011-08-25 04:41:39 +02:00
|
|
|
var model = this.getModel();
|
|
|
|
var topics = model.getTopics();
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < topics.length; i++) {
|
|
|
|
var t = topics[i];
|
|
|
|
if (t.getModel().getId() == fromNodeId) {
|
|
|
|
fromTopic = t;
|
|
|
|
}
|
|
|
|
if (t.getModel().getId() == toNodeId) {
|
|
|
|
toTopic = t;
|
|
|
|
}
|
|
|
|
if (toTopic != null && fromTopic != null) {
|
|
|
|
break;
|
|
|
|
}
|
2011-01-11 22:54:20 +01:00
|
|
|
}
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
// Create node graph ...
|
2011-08-25 04:41:39 +02:00
|
|
|
var relationLine = new mindplot.RelationshipLine(fromTopic, toTopic, topicModel.getLineType());
|
|
|
|
if ($defined(topicModel.getSrcCtrlPoint())) {
|
|
|
|
var srcPoint = topicModel.getSrcCtrlPoint().clone();
|
2011-07-27 19:53:32 +02:00
|
|
|
relationLine.setSrcControlPoint(srcPoint);
|
2011-01-11 22:54:20 +01:00
|
|
|
}
|
2011-08-25 04:41:39 +02:00
|
|
|
if ($defined(topicModel.getDestCtrlPoint())) {
|
|
|
|
var destPoint = topicModel.getDestCtrlPoint().clone();
|
2011-07-27 19:53:32 +02:00
|
|
|
relationLine.setDestControlPoint(destPoint);
|
2010-12-13 15:07:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
relationLine.getLine().setDashed(3, 2);
|
2011-08-25 04:41:39 +02:00
|
|
|
relationLine.setShowEndArrow(topicModel.getEndArrow());
|
|
|
|
relationLine.setShowStartArrow(topicModel.getStartArrow());
|
|
|
|
relationLine.setModel(topicModel);
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
//Add Listeners
|
2011-08-21 17:42:00 +02:00
|
|
|
relationLine.addEvent('onfocus', function(event) {
|
2011-07-27 19:53:32 +02:00
|
|
|
elem.onObjectFocusEvent.attempt([relationLine, event], elem);
|
|
|
|
});
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
// Append it to the workspace ...
|
2011-08-25 04:41:39 +02:00
|
|
|
this._relationships[topicModel.getId()] = relationLine;
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
return relationLine;
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
_removeNode : function(node) {
|
2011-09-06 06:03:27 +02:00
|
|
|
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE)
|
|
|
|
{
|
2011-07-27 19:53:32 +02:00
|
|
|
var parent = node._parent;
|
|
|
|
node.disconnect(this._workspace);
|
|
|
|
|
|
|
|
//remove children
|
|
|
|
while (node._getChildren().length > 0) {
|
|
|
|
this._removeNode(node._getChildren()[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._workspace.removeChild(node);
|
2011-08-25 04:41:39 +02:00
|
|
|
this.getModel().removeTopic(node);
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
// Delete this node from the model...
|
|
|
|
var model = node.getModel();
|
|
|
|
model.deleteNode();
|
|
|
|
|
|
|
|
if ($defined(parent)) {
|
2011-08-19 18:38:37 +02:00
|
|
|
this.goToNode(parent);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
deleteCurrentNode : function() {
|
|
|
|
|
2011-08-25 05:17:13 +02:00
|
|
|
var validateFunc = function(object) {
|
|
|
|
return object.getType() == mindplot.RelationshipLine.type || object.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE
|
2009-06-07 20:59:43 +02:00
|
|
|
};
|
2011-07-27 19:53:32 +02:00
|
|
|
var validateError = 'Central topic can not be deleted.';
|
2011-09-06 06:03:27 +02:00
|
|
|
|
2011-08-25 04:41:39 +02:00
|
|
|
var model = this.getModel();
|
2011-09-06 06:03:27 +02:00
|
|
|
var topicsIds = model.filterTopicsIds(validateFunc, validateError);
|
|
|
|
var relIds = model.filterRelationIds(validateFunc, validateError);
|
2011-08-25 04:41:39 +02:00
|
|
|
|
2011-09-06 06:03:27 +02:00
|
|
|
if (topicsIds.length > 0 || relIds.length > 0) {
|
|
|
|
this._actionDispatcher.deleteTopics(topicsIds,relIds);
|
2009-06-07 20:59:43 +02:00
|
|
|
}
|
|
|
|
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
changeFontFamily : function(font) {
|
2011-08-25 04:41:39 +02:00
|
|
|
var topicsIds = this.getModel().filterTopicsIds();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font);
|
|
|
|
|
2010-12-22 23:34:24 +01:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-20 16:08:18 +02:00
|
|
|
changeFontStyle : function() {
|
2011-08-25 04:41:39 +02:00
|
|
|
var topicsIds = this.getModel().filterTopicsIds();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.changeFontStyleToTopic(topicsIds);
|
2010-12-22 23:34:24 +01:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
changeFontColor : function(color) {
|
2011-08-23 19:25:49 +02:00
|
|
|
$assert(color, "color can not be null");
|
2011-08-25 04:41:39 +02:00
|
|
|
|
|
|
|
var topicsIds = this.getModel().filterTopicsIds();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.changeFontColorToTopic(topicsIds, color);
|
2009-06-07 20:59:43 +02:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
changeBackgroundColor : function(color) {
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
var validateFunc = function(topic) {
|
2011-08-08 00:27:23 +02:00
|
|
|
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE
|
2009-06-07 20:59:43 +02:00
|
|
|
};
|
2011-08-03 22:52:39 +02:00
|
|
|
var validateError = 'Color can not be set to line topics.';
|
2011-08-25 04:41:39 +02:00
|
|
|
|
|
|
|
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.changeBackgroundColorToTopic(topicsIds, color);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
changeBorderColor : function(color) {
|
2011-07-27 19:53:32 +02:00
|
|
|
var validateFunc = function(topic) {
|
2011-08-08 00:27:23 +02:00
|
|
|
return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE
|
2011-07-27 19:53:32 +02:00
|
|
|
};
|
2011-08-03 22:52:39 +02:00
|
|
|
var validateError = 'Color can not be set to line topics.';
|
2011-08-25 04:41:39 +02:00
|
|
|
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.changeBorderColorToTopic(topicsIds, color);
|
2009-06-07 20:59:43 +02:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
changeFontSize : function(size) {
|
2011-08-25 04:41:39 +02:00
|
|
|
var topicsIds = this.getModel().filterTopicsIds();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.changeFontSizeToTopic(topicsIds, size);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
2011-09-06 06:03:27 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
changeTopicShape : function(shape) {
|
2011-07-27 19:53:32 +02:00
|
|
|
var validateFunc = function(topic) {
|
2011-08-08 00:27:23 +02:00
|
|
|
return !(topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.model.NodeModel.SHAPE_TYPE_LINE)
|
2009-06-07 20:59:43 +02:00
|
|
|
};
|
2011-07-27 19:53:32 +02:00
|
|
|
var validateError = 'Central Topic shape can not be changed to line figure.';
|
2011-08-25 04:41:39 +02:00
|
|
|
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.changeShapeToTopic(topicsIds, shape);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2011-07-27 19:53:32 +02:00
|
|
|
|
2011-08-20 16:08:18 +02:00
|
|
|
changeFontWeight : function() {
|
2011-08-25 04:41:39 +02:00
|
|
|
var topicsIds = this.getModel().filterTopicsIds();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.changeFontWeightToTopic(topicsIds);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
addIconType : function(iconType) {
|
2011-08-25 04:41:39 +02:00
|
|
|
var topicsIds = this.getModel().filterTopicsIds();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.addIconToTopic(topicsIds[0], iconType);
|
2011-07-27 19:53:32 +02:00
|
|
|
}
|
2011-08-20 15:50:48 +02:00
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
addLink2Node : function(url) {
|
2011-08-25 04:41:39 +02:00
|
|
|
var topicsIds = this.getModel().filterTopicsIds();
|
2011-07-27 19:53:32 +02:00
|
|
|
if (topicsIds.length > 0) {
|
2011-08-03 22:52:39 +02:00
|
|
|
this._actionDispatcher.addLinkToTopic(topicsIds[0], url);
|
2009-06-07 20:59:43 +02:00
|
|
|
}
|
2011-07-27 19:53:32 +02:00
|
|
|
},
|
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
addLink : function() {
|
2011-08-25 04:41:39 +02:00
|
|
|
var selectedTopics = this.getModel().filterSelectedTopics();
|
2011-07-27 19:53:32 +02:00
|
|
|
var topic = null;
|
|
|
|
if (selectedTopics.length > 0) {
|
|
|
|
topic = selectedTopics[0];
|
2011-07-28 18:06:15 +02:00
|
|
|
if (!$defined(topic._hasLink)) {
|
2011-07-27 19:53:32 +02:00
|
|
|
var msg = new Element('div');
|
|
|
|
var urlText = new Element('div').inject(msg);
|
2011-08-03 22:52:39 +02:00
|
|
|
urlText.innerHTML = "URL:";
|
2011-07-27 19:53:32 +02:00
|
|
|
var formElem = new Element('form', {'action': 'none', 'id':'linkFormId'});
|
|
|
|
var urlInput = new Element('input', {'type': 'text', 'size':30});
|
|
|
|
urlInput.inject(formElem);
|
2011-08-03 22:52:39 +02:00
|
|
|
formElem.inject(msg);
|
2011-07-27 19:53:32 +02:00
|
|
|
|
|
|
|
var okButtonId = "linkOkButtonId";
|
|
|
|
formElem.addEvent('submit', function(e) {
|
|
|
|
$(okButtonId).fireEvent('click', e);
|
|
|
|
e = new Event(e);
|
|
|
|
e.stop();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var okFunction = function() {
|
|
|
|
var url = urlInput.value;
|
|
|
|
var result = false;
|
|
|
|
if ("" != url.trim()) {
|
|
|
|
this.addLink2Node(url);
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}.bind(this);
|
2011-08-26 03:08:39 +02:00
|
|
|
|
2011-07-27 19:53:32 +02:00
|
|
|
var dialog = mindplot.LinkIcon.buildDialog(this, okFunction, okButtonId);
|
|
|
|
dialog.adopt(msg).show();
|
|
|
|
|
|
|
|
// IE doesn't like too much this focus action...
|
2011-08-09 07:27:59 +02:00
|
|
|
if (!Browser.ie) {
|
2011-07-27 19:53:32 +02:00
|
|
|
urlInput.focus();
|
|
|
|
}
|
2009-06-07 20:59:43 +02:00
|
|
|
}
|
2011-07-27 19:53:32 +02:00
|
|
|
} else {
|
|
|
|
core.Monitor.getInstance().logMessage('At least one topic must be selected to execute this operation.');
|
2009-06-07 20:59:43 +02:00
|
|
|
}
|
2011-07-27 19:53:32 +02:00
|
|
|
},
|
|
|
|
|
2011-08-21 17:42:00 +02:00
|
|
|
addNote : function() {
|
2011-08-26 03:08:39 +02:00
|
|
|
var model = this.getModel();
|
|
|
|
var topic = model.selectedTopic();
|
2011-08-27 00:41:50 +02:00
|
|
|
if (topic != null) {
|
|
|
|
topic.showNoteEditor();
|
2011-07-27 19:53:32 +02:00
|
|
|
} else {
|
|
|
|
core.Monitor.getInstance().logMessage('At least one topic must be selected to execute this operation.');
|
|
|
|
}
|
|
|
|
},
|
2009-06-07 20:59:43 +02:00
|
|
|
|
2011-08-19 18:38:37 +02:00
|
|
|
goToNode : function(node) {
|
2011-07-27 19:53:32 +02:00
|
|
|
node.setOnFocus(true);
|
2011-08-19 18:38:37 +02:00
|
|
|
this.onObjectFocusEvent(node);
|
2011-07-27 19:53:32 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
getWorkSpace : function() {
|
|
|
|
return this._workspace;
|
2011-01-20 16:04:53 +01:00
|
|
|
}
|
|
|
|
}
|
2011-07-27 19:53:32 +02:00
|
|
|
);
|