First steps on icon drag support.
This commit is contained in:
@@ -160,6 +160,7 @@ mindplot.Designer = new Class({
|
||||
this._workspace.setZoom(model.getZoom(), true);
|
||||
},
|
||||
|
||||
|
||||
_buildNodeGraph : function(model, readOnly) {
|
||||
var workspace = this._workspace;
|
||||
|
||||
@@ -340,6 +341,30 @@ mindplot.Designer = new Class({
|
||||
return childModel;
|
||||
},
|
||||
|
||||
addDraddedNode: function(event, options) {
|
||||
$assert(event, "event can not be null");
|
||||
$assert(options, "option can not be null");
|
||||
|
||||
// Create a new node ...
|
||||
var mindmap = this.getMindmap();
|
||||
var model = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
model.setShapeType(mindplot.model.TopicShape.IMAGE);
|
||||
|
||||
// Set node specified options ...
|
||||
model.setImageUrl(options.imageUrl);
|
||||
model.setImageSize(options.imageWidth, options.imageHeight);
|
||||
model.setMetadata(options.metadata);
|
||||
|
||||
// Position far from the visual area ...
|
||||
model.setPosition(1000, 1000);
|
||||
|
||||
this._actionDispatcher.addTopic(model, null, false);
|
||||
var topic = this.getModel().findTopicById(model.getId());
|
||||
|
||||
// Simulate a mouse down event to start the dragging ...
|
||||
topic.fireEvent("mousedown", event);
|
||||
},
|
||||
|
||||
createSiblingForSelectedNode : function() {
|
||||
var nodes = this.getModel().filterSelectedTopics();
|
||||
if (nodes.length <= 0) {
|
||||
@@ -423,42 +448,42 @@ mindplot.Designer = new Class({
|
||||
this._mindmap = mindmapModel;
|
||||
|
||||
// try {
|
||||
// Init layout manager ...
|
||||
var size = {width:25,height:25};
|
||||
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
|
||||
layoutManager.addEvent('change', function(event) {
|
||||
var id = event.getId();
|
||||
var topic = this.getModel().findTopicById(id);
|
||||
topic.setPosition(event.getPosition());
|
||||
topic.setOrder(event.getOrder());
|
||||
}.bind(this));
|
||||
this._eventBussDispatcher.setLayoutManager(layoutManager);
|
||||
// Init layout manager ...
|
||||
var size = {width:25,height:25};
|
||||
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
|
||||
layoutManager.addEvent('change', function(event) {
|
||||
var id = event.getId();
|
||||
var topic = this.getModel().findTopicById(id);
|
||||
topic.setPosition(event.getPosition());
|
||||
topic.setOrder(event.getOrder());
|
||||
}.bind(this));
|
||||
this._eventBussDispatcher.setLayoutManager(layoutManager);
|
||||
|
||||
|
||||
// Building node graph ...
|
||||
var branches = mindmapModel.getBranches();
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
// NodeModel -> NodeGraph ...
|
||||
var nodeModel = branches[i];
|
||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
||||
// Building node graph ...
|
||||
var branches = mindmapModel.getBranches();
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
// NodeModel -> NodeGraph ...
|
||||
var nodeModel = branches[i];
|
||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
||||
|
||||
// Update shrink render state...
|
||||
nodeGraph.setBranchVisibility(true);
|
||||
}
|
||||
// Update shrink render state...
|
||||
nodeGraph.setBranchVisibility(true);
|
||||
}
|
||||
|
||||
var relationships = mindmapModel.getRelationships();
|
||||
for (var j = 0; j < relationships.length; j++) {
|
||||
this._relationshipModelToRelationship(relationships[j]);
|
||||
}
|
||||
var relationships = mindmapModel.getRelationships();
|
||||
for (var j = 0; j < relationships.length; j++) {
|
||||
this._relationshipModelToRelationship(relationships[j]);
|
||||
}
|
||||
|
||||
// Place the focus on the Central Topic
|
||||
var centralTopic = this.getModel().getCentralTopic();
|
||||
this.goToNode(centralTopic);
|
||||
// Place the focus on the Central Topic
|
||||
var centralTopic = this.getModel().getCentralTopic();
|
||||
this.goToNode(centralTopic);
|
||||
|
||||
// Finally, sort the map ...
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
// Finally, sort the map ...
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
||||
this.fireEvent('loadSuccess');
|
||||
this.fireEvent('loadSuccess');
|
||||
// } catch(e) {
|
||||
// this.fireEvent('loadError', e);
|
||||
// }
|
||||
@@ -668,7 +693,7 @@ mindplot.Designer = new Class({
|
||||
|
||||
changeBorderColor : function(color) {
|
||||
var validateFunc = function(topic) {
|
||||
return topic.getShapeType() != mindplot.model.TopicShape.LINE ;
|
||||
return topic.getShapeType() != mindplot.model.TopicShape.LINE;
|
||||
};
|
||||
var validateError = 'Color can not be set to line topics.';
|
||||
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||
|
Reference in New Issue
Block a user