Bug WA-57 fixed. #resolve

This commit is contained in:
Paulo Gustavo Veiga 2015-04-11 19:41:45 -03:00
parent 928ef3d813
commit cbaaed7810

View File

@ -24,7 +24,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {HTMLElement} divElement
* @extends mindplot.Events
*/
initialize:function (options, divElement) {
initialize: function (options, divElement) {
$assert(options, "options must be defined");
$assert(options.zoom, "zoom must be defined");
$assert(options.size, "size must be defined");
@ -81,7 +81,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
/**
* @private
*/
_registerWheelEvents:function () {
_registerWheelEvents: function () {
var workspace = this._workspace;
var me = this;
// Zoom In and Zoom Out must active event
@ -118,7 +118,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {Function} listener
* forwards to the TopicEventDispatcher or the parent Events class, depending on the type
*/
addEvent:function (type, listener) {
addEvent: function (type, listener) {
if (type == mindplot.TopicEvent.EDIT || type == mindplot.TopicEvent.CLICK) {
var editor = mindplot.TopicEventDispatcher.getInstance();
editor.addEvent(type, listener);
@ -130,7 +130,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
/**
* @private
*/
_registerMouseEvents:function () {
_registerMouseEvents: function () {
var workspace = this._workspace;
var screenManager = workspace.getScreenManager();
var me = this;
@ -138,7 +138,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
screenManager.addEvent('update', function () {
// Topic must be set to his original state. All editors must be closed.
var topics = me.getModel().getTopics();
_.each(topics, function(object){
_.each(topics, function (object) {
object.closeEditors();
});
@ -160,13 +160,13 @@ mindplot.Designer = new Class(/** @lends Designer */{
var model = me._createChildModel(centralTopic, mousePos);
this._actionDispatcher.addTopics([model], [centralTopic.getId()]);
}
});
}.bind(this));
// Register mouse drag and drop event ...
function noopHandler(evt) {
evt.stopPropagation();
evt.preventDefault();
};
}
},
/**
@ -175,7 +175,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @return {mindplot.DragManager} the new dragManager for the workspace with events
* registered
*/
_buildDragManager:function (workspace) {
_buildDragManager: function (workspace) {
var designerModel = this.getModel();
var dragConnector = new mindplot.DragConnector(designerModel, this._workspace);
@ -215,7 +215,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {width:Number, height:Number} size
* sets width and height of the workspace
*/
setViewPort:function (size) {
setViewPort: function (size) {
this._workspace.setViewPort(size);
var model = this.getModel();
this._workspace.setZoom(model.getZoom(), true);
@ -228,9 +228,9 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @return {mindplot.CentralTopic|mindplot.MainTopic} the topic to the given model,
* connected, added to the drag manager, with events registered - complying type & read mode
*/
_buildNodeGraph:function (model, readOnly) {
_buildNodeGraph: function (model, readOnly) {
// Create node graph ...
var topic = mindplot.NodeGraph.create(model, {readOnly:readOnly});
var topic = mindplot.NodeGraph.create(model, {readOnly: readOnly});
this.getModel().addTopic(topic);
var me = this;
// Add Topic events ...
@ -296,16 +296,16 @@ mindplot.Designer = new Class(/** @lends Designer */{
* sets focus to the given currentObject and removes it from any other objects if not
* triggered with Ctrl pressed
*/
onObjectFocusEvent:function (currentObject, event) {
onObjectFocusEvent: function (currentObject, event) {
// Close node editors ..
var topics = this.getModel().getTopics();
_.each(topics, function(topic) {
_.each(topics, function (topic) {
topic.closeEditors();
});
var model = this.getModel();
var objects = model.getEntities();
_.each(objects, function(object) {
_.each(objects, 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)) {
if (object.isOnFocus() && object != currentObject) {
@ -317,16 +317,16 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** sets focus to all model entities, i.e. relationships and topics */
selectAll:function () {
selectAll: function () {
var model = this.getModel();
var objects = model.getEntities();
_.each(objects, function(object) {
_.each(objects, function (object) {
object.setOnFocus(true);
});
},
/** removes focus from all model entities, i.e. relationships and topics */
deselectAll:function () {
deselectAll: function () {
var objects = this.getModel().getEntities();
_.each(objects, function (object) {
object.setOnFocus(false);
@ -337,7 +337,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* Set the zoom of the map
* @param {Number} zoom number between 0.3 and 1.9
*/
setZoom:function (zoom) {
setZoom: function (zoom) {
if (zoom > 1.9 || zoom < 0.3) {
$notify($msg('ZOOM_IN_ERROR'));
return;
@ -350,7 +350,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {Number=} factor
* zoom out by the given factor, or 1.2, if undefined
*/
zoomOut:function (factor) {
zoomOut: function (factor) {
if (!factor)
factor = 1.2;
@ -370,7 +370,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {Number=} factor
* zoom in by the given factor, or 1.2, if undefined
*/
zoomIn:function (factor) {
zoomIn: function (factor) {
if (!factor)
factor = 1.2;
@ -387,7 +387,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** copy selected topics to a private clipboard */
copyToClipboard:function () {
copyToClipboard: function () {
var topics = this.getModel().filterSelectedTopics();
if (topics.length <= 0) {
// If there are more than one node selected,
@ -414,7 +414,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** paste clipboard contents to the mindmap */
pasteClipboard:function () {
pasteClipboard: function () {
if (this._clipboard.length == 0) {
$notify($msg('CLIPBOARD_IS_EMPTY'));
return;
@ -424,12 +424,12 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** @return {mindplot.DesignerModel} model */
getModel:function () {
getModel: function () {
return this._model;
},
/** collapse the subtree of the selected topic */
shrinkSelectedBranch:function () {
shrinkSelectedBranch: function () {
var nodes = this.getModel().filterSelectedTopics();
if (nodes.length <= 0 || nodes.length != 1) {
// If there are more than one node selected,
@ -445,7 +445,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** create a NodeModel for the selected node's child and add it via the ActionDispatcher */
createChildForSelectedNode:function () {
createChildForSelectedNode: function () {
var nodes = this.getModel().filterSelectedTopics();
if (nodes.length <= 0) {
// If there are more than one node selected,
@ -473,49 +473,48 @@ mindplot.Designer = new Class(/** @lends Designer */{
/**
* @private
*/
_copyNodeProps: function(sourceModel,targetModel){
_copyNodeProps: function (sourceModel, targetModel) {
// I don't copy the font size if the target is the source is the central topic.
if(sourceModel.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE)
{
if (sourceModel.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
var fontSize = sourceModel.getFontSize();
if(fontSize){
if (fontSize) {
targetModel.setFontSize(fontSize)
}
}
var fontFamily = sourceModel.getFontFamily();
if(fontFamily){
if (fontFamily) {
targetModel.setFontFamily(fontFamily)
}
var fontColor = sourceModel.getFontColor();
if(fontColor){
if (fontColor) {
targetModel.setFontColor(fontColor)
}
var fontWeight = sourceModel.getFontWeight();
if(fontWeight){
if (fontWeight) {
targetModel.setFontWeight(fontWeight)
}
var fontStyle = sourceModel.getFontStyle();
if(fontStyle){
if (fontStyle) {
targetModel.setFontStyle(fontStyle)
}
var shape = sourceModel.getShapeType();
if(shape){
if (shape) {
targetModel.setShapeType(shape)
}
var borderColor = sourceModel.getBorderColor();
if(borderColor){
if (borderColor) {
targetModel.setBorderColor(borderColor)
}
var backgroundColor = sourceModel.getBackgroundColor();
if(backgroundColor){
if (backgroundColor) {
targetModel.setBackgroundColor(backgroundColor)
}
},
@ -526,7 +525,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {core.Point} mousePos the mouse position
* @return {mindplot.NodeModel} the node model for the new child
*/
_createChildModel:function (topic, mousePos) {
_createChildModel: function (topic, mousePos) {
// Create a new node ...
var parentModel = topic.getModel();
var mindmap = parentModel.getMindmap();
@ -540,7 +539,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
var position = result.position;
childModel.setPosition(position.x, position.y);
this._copyNodeProps(parentModel,childModel);
this._copyNodeProps(parentModel, childModel);
return childModel;
},
@ -550,7 +549,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {mindplot.model.NodeModel} model
* @todo not used
*/
addDraggedNode:function (event, model) {
addDraggedNode: function (event, model) {
$assert(event, "event can not be null");
$assert(model, "model can not be null");
@ -568,7 +567,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* creates a sibling or child node of the selected node, if the selected node is the
* central topic
*/
createSiblingForSelectedNode:function () {
createSiblingForSelectedNode: function () {
var nodes = this.getModel().filterSelectedTopics();
if (nodes.length <= 0) {
// If there are no nodes selected,
@ -607,7 +606,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {mindplot.Topic} topic the topic to create the sibling to
* @return {mindplot.NodeModel} the node model of the sibling
*/
_createSiblingModel:function (topic) {
_createSiblingModel: function (topic) {
var result = null;
var parentTopic = topic.getOutgoingConnectedTopic();
if (parentTopic != null) {
@ -623,7 +622,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
result.setPosition(10, 10); // Set a dummy position ...
}
this._copyNodeProps(model,result);
this._copyNodeProps(model, result);
return result;
},
@ -631,7 +630,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
/**
* @param {Event} event
*/
showRelPivot:function (event) {
showRelPivot: function (event) {
var nodes = this.getModel().filterSelectedTopics();
if (nodes.length <= 0) {
@ -649,20 +648,20 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** @return the zoom */
getMindmapProperties:function () {
return {zoom:this.getModel().getZoom()};
getMindmapProperties: function () {
return {zoom: this.getModel().getZoom()};
},
/**
* @param {mindplot.Mindmap} mindmapModel
* @throws will throw an error if mindmapModel is null or undefined
*/
loadMap:function (mindmapModel) {
loadMap: function (mindmapModel) {
$assert(mindmapModel, "mindmapModel can not be null");
this._mindmap = mindmapModel;
// Init layout manager ...
var size = {width:25, height:25};
var size = {width: 25, height: 25};
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
var me = this;
layoutManager.addEvent('change', function (event) {
@ -701,23 +700,23 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
getMindmap:function () {
getMindmap: function () {
return this._mindmap;
},
/** */
undo:function () {
undo: function () {
// @Todo: This is a hack...
this._actionDispatcher._actionRunner.undo();
},
/** */
redo:function () {
redo: function () {
this._actionDispatcher._actionRunner.redo();
},
/** */
isReadOnly:function () {
isReadOnly: function () {
return this._options.readOnly;
},
@ -725,7 +724,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {mindplot.model.NodeModel} nodeModel
* @return {mindplot.Topic} the topic (extends mindplot.NodeGraph) created to the model
*/
nodeModelToNodeGraph:function (nodeModel) {
nodeModelToNodeGraph: function (nodeModel) {
$assert(nodeModel, "Node model can not be null");
var children = nodeModel.getChildren().slice();
children = children.sort(function (a, b) {
@ -751,7 +750,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @return {mindplot.Relationship} the relationship created to the model
* @throws will throw an error if model is null or undefined
*/
_relationshipModelToRelationship:function (model) {
_relationshipModelToRelationship: function (model) {
$assert(model, "Node model can not be null");
var result = this._buildRelationshipShape(model);
@ -772,7 +771,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {mindplot.model.RelationshipModel} model
* @return {mindplot.Relationship} the relationship added to the mindmap
*/
addRelationship:function (model) {
addRelationship: function (model) {
var mindmap = this.getMindmap();
mindmap.addRelationship(model);
return this._relationshipModelToRelationship(model);
@ -782,7 +781,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* deletes the relationship from the linked topics, DesignerModel, Workspace and Mindmap
* @param {mindplot.Relationship} rel the relationship to delete
*/
deleteRelationship:function (rel) {
deleteRelationship: function (rel) {
var sourceTopic = rel.getSourceTopic();
sourceTopic.deleteRelationship(rel);
@ -802,7 +801,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @return {mindplot.Relationship} the new relationship with events registered
* @throws will throw an error if the target topic cannot be found
*/
_buildRelationshipShape:function (model) {
_buildRelationshipShape: function (model) {
var dmodel = this.getModel();
var sourceTopicId = model.getFromNode();
@ -846,7 +845,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {mindplot.model.Topic} node the topic to remove
* removes the given topic and its children from Workspace, DesignerModel and NodeModel
*/
removeTopic:function (node) {
removeTopic: function (node) {
if (!node.isCentralTopic()) {
var parent = node._parent;
node.disconnect(this._workspace);
@ -872,7 +871,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
/**
* @private
*/
_resetEdition:function () {
_resetEdition: function () {
var screenManager = this._workspace.getScreenManager();
screenManager.fireEvent("update");
screenManager.fireEvent("mouseup");
@ -880,7 +879,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
deleteSelectedEntities:function () {
deleteSelectedEntities: function () {
// Is there some action in progress ?.
this._resetEdition();
@ -915,7 +914,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
changeFontFamily:function (font) {
changeFontFamily: function (font) {
var topicsIds = this.getModel().filterTopicsIds();
if (topicsIds.length > 0) {
this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font);
@ -924,7 +923,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
changeFontStyle:function () {
changeFontStyle: function () {
var topicsIds = this.getModel().filterTopicsIds();
if (topicsIds.length > 0) {
this._actionDispatcher.changeFontStyleToTopic(topicsIds);
@ -932,7 +931,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
changeFontColor:function (color) {
changeFontColor: function (color) {
$assert(color, "color can not be null");
var topicsIds = this.getModel().filterTopicsIds();
@ -942,7 +941,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
changeBackgroundColor:function (color) {
changeBackgroundColor: function (color) {
var validateFunc = function (topic) {
return topic.getShapeType() != mindplot.model.TopicShape.LINE;
@ -956,7 +955,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
changeBorderColor:function (color) {
changeBorderColor: function (color) {
var validateFunc = function (topic) {
return topic.getShapeType() != mindplot.model.TopicShape.LINE;
};
@ -968,7 +967,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
changeFontSize:function (size) {
changeFontSize: function (size) {
var topicsIds = this.getModel().filterTopicsIds();
if (topicsIds.length > 0) {
this._actionDispatcher.changeFontSizeToTopic(topicsIds, size);
@ -976,7 +975,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
changeTopicShape:function (shape) {
changeTopicShape: function (shape) {
var validateFunc = function (topic) {
return !(topic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.model.TopicShape.LINE)
};
@ -989,7 +988,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
changeFontWeight:function () {
changeFontWeight: function () {
var topicsIds = this.getModel().filterTopicsIds();
if (topicsIds.length > 0) {
this._actionDispatcher.changeFontWeightToTopic(topicsIds);
@ -997,10 +996,10 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
addIconType:function (iconType) {
addIconType: function (iconType) {
var topicsIds = this.getModel().filterTopicsIds();
if (topicsIds.length > 0) {
this._actionDispatcher.addFeatureToTopic(topicsIds[0], mindplot.TopicFeature.Icon.id, {id:iconType});
this._actionDispatcher.addFeatureToTopic(topicsIds[0], mindplot.TopicFeature.Icon.id, {id: iconType});
}
},
@ -1008,7 +1007,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
* lets the selected topic open the link editor where the user can define or modify an
* existing link
*/
addLink:function () {
addLink: function () {
var model = this.getModel();
var topic = model.selectedTopic();
if (topic) {
@ -1018,7 +1017,7 @@ mindplot.Designer = new Class(/** @lends Designer */{
},
/** */
addNote:function () {
addNote: function () {
var model = this.getModel();
var topic = model.selectedTopic();
if (topic) {
@ -1031,13 +1030,13 @@ mindplot.Designer = new Class(/** @lends Designer */{
* @param {mindplot.Topic} node
* sets the focus to the given node
*/
goToNode:function (node) {
goToNode: function (node) {
node.setOnFocus(true);
this.onObjectFocusEvent(node);
},
/** @return {mindplot.Workspace} */
getWorkSpace:function () {
getWorkSpace: function () {
return this._workspace;
}
}