mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-20 11:10:07 +02:00
133 lines
4.6 KiB
JavaScript
133 lines
4.6 KiB
JavaScript
/*
|
|
* 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.BrixActionDispatcher = new Class({
|
|
Extends: mindplot.ActionDispatcher,
|
|
initialize: function(commandContext, fireOnChange) {
|
|
this.parent(commandContext, fireOnChange);
|
|
this._commandContext = commandContext;
|
|
},
|
|
|
|
changeTextToTopic : function(topicsIds, text) {
|
|
var framework = this._getFramework();
|
|
var topicId;
|
|
if (!(topicsIds instanceof Array)) {
|
|
topicId = topicsIds;
|
|
} else {
|
|
topicId = topicsIds[0];
|
|
}
|
|
var topic = framework.getTopic(topicId);
|
|
topic.setText(text, true);
|
|
},
|
|
|
|
_getFramework:function () {
|
|
return mindplot.collaboration.CollaborationManager.getInstance().getCollaborativeFramework();
|
|
},
|
|
|
|
addTopic : function(model, parentTopicId, animated) {
|
|
var framework = this._getFramework();
|
|
var mindmap = framework.getModel();
|
|
var centralTopic = mindmap.getCentralTopic();
|
|
|
|
var newNode = mindmap.createNode(model.getType(), model.getId());
|
|
var position = model.getPosition();
|
|
newNode.setPosition(position.x, position.y);
|
|
newNode.connectTo(centralTopic);
|
|
},
|
|
|
|
changeFontSizeToTopic : function(topicsIds, size) {
|
|
topicsIds.forEach(function(topicId) {
|
|
var framework = this._getFramework();
|
|
var topic = framework.getTopic(topicId);
|
|
topic.setFontSize(size, true);
|
|
}.bind(this));
|
|
},
|
|
|
|
changeFontColorToTopic : function(topicsIds, color) {
|
|
topicsIds.forEach(function(topicId) {
|
|
var framework = this._getFramework();
|
|
var topic = framework.getTopic(topicId);
|
|
topic.setFontColor(color, true);
|
|
}.bind(this));
|
|
},
|
|
|
|
changeFontFamilyToTopic : function(topicsIds, family) {
|
|
topicsIds.forEach(function(topicId) {
|
|
var framework = this._getFramework();
|
|
var topic = framework.getTopic(topicId);
|
|
topic.setFontFamily(family, true);
|
|
}.bind(this));
|
|
},
|
|
|
|
changeFontStyleToTopic : function(topicsIds) {
|
|
topicsIds.forEach(function(topicId) {
|
|
var framework = this._getFramework();
|
|
var topic = framework.getTopic(topicId);
|
|
var style = ( topic.getFontStyle() == "italic") ? "normal" : "italic";
|
|
topic.setFontStyle(style, true);
|
|
}.bind(this));
|
|
},
|
|
|
|
changeShapeToTopic : function(topicsIds, shapeType) {
|
|
topicsIds.forEach(function(topicId) {
|
|
var framework = this._getFramework();
|
|
var topic = framework.getTopic(topicId);
|
|
topic.setShapeType(shapeType);
|
|
}.bind(this))
|
|
},
|
|
|
|
changeFontWeightToTopic : function(topicsIds) {
|
|
topicsIds.forEach(function(topicId) {
|
|
var framework = this._getFramework();
|
|
var topic = framework.getTopic(topicId);
|
|
var weight = (topic.getFontWeight() == "bold") ? "normal" : "bold";
|
|
topic.setFontWeight(weight, true);
|
|
}.bind(this));
|
|
},
|
|
|
|
changeBackgroundColorToTopic : function(topicsIds, color) {
|
|
topicsIds.forEach(function(topicId) {
|
|
var framework = this._getFramework();
|
|
var topic = framework.getTopic(topicId);
|
|
topic.setBackgroundColor(color, true);
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
changeBorderColorToTopic : function(topicsIds, color) {
|
|
topicsIds.forEach(function(topicId) {
|
|
var framework = this._getFramework();
|
|
var topic = framework.getTopic(topicId);
|
|
topic.setBorderColor(color);
|
|
}.bind(this));
|
|
},
|
|
|
|
deleteTopics : function(topicsIds, relIds) {
|
|
$assert(topicsIds, "topicsIds can not be null");
|
|
var framework = this._getFramework();
|
|
var mindmap = framework.getModel();
|
|
|
|
var topicId = topicsIds[0];
|
|
var topic = framework.getTopic(topicId);
|
|
$assert(topic, "Could not find topic with id:" + topicId);
|
|
mindmap.disconnect(topic);
|
|
|
|
}
|
|
});
|
|
|