- Change forEach for each interator

- Fix issue deleting nodes with intermediate relationships
This commit is contained in:
Paulo Gustavo Veiga 2012-07-08 19:31:21 -03:00
parent 8175eea928
commit 39c2b37a1f
24 changed files with 521 additions and 508 deletions

View File

@ -73,7 +73,7 @@ mindplot.BrixActionDispatcher = new Class({
}, },
changeFontSizeToTopic : function(topicsIds, size) { changeFontSizeToTopic : function(topicsIds, size) {
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var framework = this._getFramework(); var framework = this._getFramework();
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
topic.setFontSize(size, true); topic.setFontSize(size, true);
@ -81,7 +81,7 @@ mindplot.BrixActionDispatcher = new Class({
}, },
changeFontColorToTopic : function(topicsIds, color) { changeFontColorToTopic : function(topicsIds, color) {
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var framework = this._getFramework(); var framework = this._getFramework();
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
topic.setFontColor(color, true); topic.setFontColor(color, true);
@ -89,7 +89,7 @@ mindplot.BrixActionDispatcher = new Class({
}, },
changeFontFamilyToTopic : function(topicsIds, family) { changeFontFamilyToTopic : function(topicsIds, family) {
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var framework = this._getFramework(); var framework = this._getFramework();
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
topic.setFontFamily(family, true); topic.setFontFamily(family, true);
@ -97,7 +97,7 @@ mindplot.BrixActionDispatcher = new Class({
}, },
changeFontStyleToTopic : function(topicsIds) { changeFontStyleToTopic : function(topicsIds) {
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var framework = this._getFramework(); var framework = this._getFramework();
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
var style = ( topic.getFontStyle() == "italic") ? "normal" : "italic"; var style = ( topic.getFontStyle() == "italic") ? "normal" : "italic";
@ -106,7 +106,7 @@ mindplot.BrixActionDispatcher = new Class({
}, },
changeShapeTypeToTopic : function(topicsIds, shapeType) { changeShapeTypeToTopic : function(topicsIds, shapeType) {
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var framework = this._getFramework(); var framework = this._getFramework();
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
topic.setShapeType(shapeType); topic.setShapeType(shapeType);
@ -114,7 +114,7 @@ mindplot.BrixActionDispatcher = new Class({
}, },
changeFontWeightToTopic : function(topicsIds) { changeFontWeightToTopic : function(topicsIds) {
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var framework = this._getFramework(); var framework = this._getFramework();
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
var weight = (topic.getFontWeight() == "bold") ? "normal" : "bold"; var weight = (topic.getFontWeight() == "bold") ? "normal" : "bold";
@ -123,7 +123,7 @@ mindplot.BrixActionDispatcher = new Class({
}, },
changeBackgroundColorToTopic : function(topicsIds, color) { changeBackgroundColorToTopic : function(topicsIds, color) {
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var framework = this._getFramework(); var framework = this._getFramework();
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
topic.setBackgroundColor(color, true); topic.setBackgroundColor(color, true);
@ -132,7 +132,7 @@ mindplot.BrixActionDispatcher = new Class({
}, },
changeBorderColorToTopic : function(topicsIds, color) { changeBorderColorToTopic : function(topicsIds, color) {
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var framework = this._getFramework(); var framework = this._getFramework();
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
topic.setBorderColor(color); topic.setBorderColor(color);
@ -144,7 +144,7 @@ mindplot.BrixActionDispatcher = new Class({
var framework = this._getFramework(); var framework = this._getFramework();
var mindmap = framework.getModel(); var mindmap = framework.getModel();
topicsIds.forEach(function(topicId) { topicsIds.each(function(topicId) {
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
topic.deleteNode(); topic.deleteNode();
}); });

View File

@ -109,7 +109,7 @@ mindplot.Designer = new Class({
screenManager.addEvent('update', function () { screenManager.addEvent('update', function () {
// Topic must be set to his original state. All editors must be closed. // Topic must be set to his original state. All editors must be closed.
var topics = this.getModel().getTopics(); var topics = this.getModel().getTopics();
topics.forEach(function (object) { topics.each(function (object) {
object.closeEditors(); object.closeEditors();
}); });
@ -271,13 +271,13 @@ mindplot.Designer = new Class({
onObjectFocusEvent:function (currentObject, event) { onObjectFocusEvent:function (currentObject, event) {
// Close node editors .. // Close node editors ..
var topics = this.getModel().getTopics(); var topics = this.getModel().getTopics();
topics.forEach(function (topic) { topics.each(function (topic) {
topic.closeEditors(); topic.closeEditors();
}); });
var model = this.getModel(); var model = this.getModel();
var objects = model.getEntities(); var objects = model.getEntities();
objects.forEach(function (object) { objects.each(function (object) {
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed // Disable all nodes on focus but not the current if Ctrl key isn't being pressed
if (!$defined(event) || (!event.control && !event.meta)) { if (!$defined(event) || (!event.control && !event.meta)) {
if (object.isOnFocus() && object != currentObject) { if (object.isOnFocus() && object != currentObject) {
@ -291,14 +291,14 @@ mindplot.Designer = new Class({
selectAll:function () { selectAll:function () {
var model = this.getModel(); var model = this.getModel();
var objects = model.getEntities(); var objects = model.getEntities();
objects.forEach(function (object) { objects.each(function (object) {
object.setOnFocus(true); object.setOnFocus(true);
}); });
}, },
deselectAll:function () { deselectAll:function () {
var objects = this.getModel().getEntities(); var objects = this.getModel().getEntities();
objects.forEach(function (object) { objects.each(function (object) {
object.setOnFocus(false); object.setOnFocus(false);
}); });
}, },

View File

@ -103,7 +103,7 @@ mindplot.IconGroup = new Class({
this._resize(this._icons.length); this._resize(this._icons.length);
// Add all again ... // Add all again ...
this._icons.forEach(function(elem, i) { this._icons.each(function(elem, i) {
this._positionIcon(elem, i); this._positionIcon(elem, i);
}.bind(this)); }.bind(this));
}, },

View File

@ -103,7 +103,7 @@ mindplot.MultilineTextEditor = new Class({
var lines = textElem.value.split('\n'); var lines = textElem.value.split('\n');
var maxLineLength = 1; var maxLineLength = 1;
lines.forEach(function(line) { lines.each(function(line) {
if (maxLineLength < line.length) if (maxLineLength < line.length)
maxLineLength = line.length; maxLineLength = line.length;
}); });

View File

@ -53,7 +53,7 @@ mindplot.RelationshipPivot = new Class({
// Register focus events on all topics ... // Register focus events on all topics ...
var model = this._designer.getModel(); var model = this._designer.getModel();
var topics = model.getTopics(); var topics = model.getTopics();
topics.forEach(function (topic) { topics.each(function (topic) {
topic.addEvent('ontfocus', this._onTopicClick); topic.addEvent('ontfocus', this._onTopicClick);
}.bind(this)); }.bind(this));
} }
@ -69,7 +69,7 @@ mindplot.RelationshipPivot = new Class({
var model = this._designer.getModel(); var model = this._designer.getModel();
var topics = model.getTopics(); var topics = model.getTopics();
topics.forEach(function (topic) { topics.each(function (topic) {
topic.removeEvent('ontfocus', this._onTopicClick); topic.removeEvent('ontfocus', this._onTopicClick);
}.bind(this)); }.bind(this));

View File

@ -55,7 +55,7 @@ mindplot.ScreenManager = new Class({
fireEvent : function(type, event) { fireEvent : function(type, event) {
if (type == 'click') { if (type == 'click') {
this._clickEvents.forEach(function(listener) { this._clickEvents.each(function(listener) {
listener(type, event); listener(type, event);
}); });
} }

View File

@ -875,7 +875,7 @@ mindplot.Topic = new Class({
}, },
_setRelationshipLinesVisibility:function (value) { _setRelationshipLinesVisibility:function (value) {
this._relationships.forEach(function (relationship) { this._relationships.each(function (relationship) {
relationship.setVisibility(value); relationship.setVisibility(value);
}); });
}, },

View File

@ -29,7 +29,7 @@ mindplot.commands.AddTopicCommand = new Class({
execute:function (commandContext) { execute:function (commandContext) {
this._models.forEach(function (model, index) { this._models.each(function (model, index) {
// Add a new topic ... // Add a new topic ...
var topic = commandContext.createTopic(model, false); var topic = commandContext.createTopic(model, false);
@ -56,7 +56,7 @@ mindplot.commands.AddTopicCommand = new Class({
undoExecute:function (commandContext) { undoExecute:function (commandContext) {
// Finally, delete the topic from the workspace ... // Finally, delete the topic from the workspace ...
this._models.forEach(function (model) { this._models.each(function (model) {
var topicId = model.getId(); var topicId = model.getId();
var topic = commandContext.findTopics(topicId)[0]; var topic = commandContext.findTopics(topicId)[0];

View File

@ -36,63 +36,61 @@ mindplot.commands.DeleteCommand = new Class({
if (topics.length > 0) { if (topics.length > 0) {
topics.forEach( topics.each(function (topic) {
function (topic) { var model = topic.getModel();
var model = topic.getModel();
// Delete relationships // Delete relationships
var relationships = topic.getRelationships(); var relationships = this._collectInDepthRelationships(topic);
while (relationships.length > 0) { this._deletedRelModel.append(relationships.map(function (rel) {
var relationship = relationships[0]; return rel.getModel().clone();
}));
this._deletedRelModel.push(relationship.getModel().clone()); relationships.each(function (relationship) {
commandContext.deleteRelationship(relationship); commandContext.deleteRelationship(relationship);
} });
// Store information for undo ... // Store information for undo ...
var clonedModel = model.clone(); var clonedModel = model.clone();
this._deletedTopicModels.push(clonedModel); this._deletedTopicModels.push(clonedModel);
var outTopic = topic.getOutgoingConnectedTopic(); var outTopic = topic.getOutgoingConnectedTopic();
var outTopicId = null; var outTopicId = null;
if (outTopic != null) { if (outTopic != null) {
outTopicId = outTopic.getId(); outTopicId = outTopic.getId();
} }
this._parentTopicIds.push(outTopicId); this._parentTopicIds.push(outTopicId);
// Finally, delete the topic from the workspace... // Finally, delete the topic from the workspace...
commandContext.deleteTopic(topic); commandContext.deleteTopic(topic);
}.bind(this) }, this);
);
} }
var rels = commandContext.findRelationships(this._relIds); var rels = commandContext.findRelationships(this._relIds);
if (rels.length > 0) { if (rels.length > 0) {
rels.forEach(function (rel) { rels.each(function (rel) {
this._deletedRelModel.push(rel.getModel().clone()); this._deletedRelModel.push(rel.getModel().clone());
commandContext.deleteRelationship(rel); commandContext.deleteRelationship(rel);
}.bind(this)); }, this);
} }
}, },
undoExecute:function (commandContext) { undoExecute:function (commandContext) {
var parent = commandContext.findTopics(this._parentTopicIds); var parent = commandContext.findTopics(this._parentTopicIds);
this._deletedTopicModels.forEach( this._deletedTopicModels.each(function (model, index) {
function (model, index) { var topic = commandContext.createTopic(model);
var topic = commandContext.createTopic(model);
// Was the topic connected? // Was the topic connected?
var parentTopic = parent[index]; var parentTopic = parent[index];
if (parentTopic != null) { if (parentTopic != null) {
commandContext.connect(topic, parentTopic); commandContext.connect(topic, parentTopic);
topic.setOnFocus(true); topic.setOnFocus(true);
} }
}.bind(this) }, this);
);
this._deletedRelModel.forEach(function (model) { this._deletedRelModel.each(function (model) {
commandContext.addRelationship(model); commandContext.addRelationship(model);
}.bind(this)); }.bind(this));
@ -105,7 +103,7 @@ mindplot.commands.DeleteCommand = new Class({
var topics = commandContext.findTopics(topicIds); var topics = commandContext.findTopics(topicIds);
var result = []; var result = [];
topics.forEach(function (topic) { topics.each(function (topic) {
var parent = topic.getParent(); var parent = topic.getParent();
var found = false; var found = false;
while (parent != null && !found) { while (parent != null && !found) {
@ -121,6 +119,21 @@ mindplot.commands.DeleteCommand = new Class({
} }
}); });
return result;
},
_collectInDepthRelationships:function (topic) {
var result = [];
var children = topic.getChildren();
if (children.length > 0) {
var rels = children.map(function (topic) {
return this._collectInDepthRelationships(topic);
}, this);
result.append(rels.flatten());
} else {
result.append(topic.getRelationships());
}
return result; return result;
} }
}); });

View File

@ -32,7 +32,7 @@ mindplot.commands.GenericFunctionCommand = new Class({
execute: function(commandContext) { execute: function(commandContext) {
if (!this.applied) { if (!this.applied) {
var topics = commandContext.findTopics(this._topicsIds); var topics = commandContext.findTopics(this._topicsIds);
topics.forEach(function(topic) { topics.each(function(topic) {
var oldValue = this._commandFunc(topic, this._value); var oldValue = this._commandFunc(topic, this._value);
this._oldValues.push(oldValue); this._oldValues.push(oldValue);
}.bind(this)); }.bind(this));
@ -46,7 +46,7 @@ mindplot.commands.GenericFunctionCommand = new Class({
undoExecute: function(commandContext) { undoExecute: function(commandContext) {
if (this.applied) { if (this.applied) {
var topics = commandContext.findTopics(this._topicsIds); var topics = commandContext.findTopics(this._topicsIds);
topics.forEach(function(topic, index) { topics.each(function(topic, index) {
this._commandFunc(topic, this._oldValues[index]); this._commandFunc(topic, this._oldValues[index]);
}.bind(this)); }.bind(this));

View File

@ -38,7 +38,7 @@ mindplot.layout.AbstractBasicSorter = new Class({
result = height; result = height;
} else { } else {
var childrenHeight = 0; var childrenHeight = 0;
children.forEach(function(child) { children.each(function(child) {
childrenHeight += this._computeChildrenHeight(treeSet, child, heightCache); childrenHeight += this._computeChildrenHeight(treeSet, child, heightCache);
}, this); }, this);

View File

@ -154,7 +154,7 @@ mindplot.layout.BalancedSorter = new Class({
var totalPHeight = 0; var totalPHeight = 0;
var totalNHeight = 0; var totalNHeight = 0;
heights.forEach(function (elem) { heights.each(function (elem) {
if (elem.order % 2 == 0) { if (elem.order % 2 == 0) {
totalPHeight += elem.height; totalPHeight += elem.height;
} else { } else {

View File

@ -143,7 +143,7 @@ mindplot.layout.LayoutManager = new Class({
}, },
_flushEvents: function() { _flushEvents: function() {
this._events.forEach(function(event) { this._events.each(function(event) {
this.fireEvent('change', event); this.fireEvent('change', event);
}, this); }, this);
this._events = []; this._events = [];
@ -153,7 +153,7 @@ mindplot.layout.LayoutManager = new Class({
if (!nodes) if (!nodes)
nodes = this._treeSet.getTreeRoots(); nodes = this._treeSet.getTreeRoots();
nodes.forEach(function(node) { nodes.each(function(node) {
if (node.hasOrderChanged() || node.hasPositionChanged()) { if (node.hasOrderChanged() || node.hasPositionChanged()) {
// Find or create a event ... // Find or create a event ...

View File

@ -70,7 +70,7 @@ mindplot.layout.OriginalLayout = new Class({
layout:function () { layout:function () {
var roots = this._treeSet.getTreeRoots(); var roots = this._treeSet.getTreeRoots();
roots.forEach(function (node) { roots.each(function (node) {
// Calculate all node heights ... // Calculate all node heights ...
var sorter = node.getSorter(); var sorter = node.getSorter();
@ -108,7 +108,7 @@ mindplot.layout.OriginalLayout = new Class({
var offsetById = sorter.computeOffsets(this._treeSet, node); var offsetById = sorter.computeOffsets(this._treeSet, node);
var parentPosition = node.getPosition(); var parentPosition = node.getPosition();
children.forEach(function (child) { children.each(function (child) {
var offset = offsetById[child.getId()]; var offset = offsetById[child.getId()];
var childFreeDisplacement = child.getFreeDisplacement(); var childFreeDisplacement = child.getFreeDisplacement();
@ -133,7 +133,7 @@ mindplot.layout.OriginalLayout = new Class({
} }
// Continue reordering the children nodes ... // Continue reordering the children nodes ...
children.forEach(function (child) { children.each(function (child) {
this._layoutChildren(child, heightById); this._layoutChildren(child, heightById);
}, this); }, this);
}, },
@ -183,7 +183,7 @@ mindplot.layout.OriginalLayout = new Class({
this._shiftBranches(node, heightById); this._shiftBranches(node, heightById);
} }
children.forEach(function (child) { children.each(function (child) {
this._fixOverlapping(child, heightById); this._fixOverlapping(child, heightById);
}, this); }, this);
}, },
@ -193,7 +193,7 @@ mindplot.layout.OriginalLayout = new Class({
var siblingsToShift = this._treeSet.getSiblingsInVerticalDirection(node, node.getFreeDisplacement().y); var siblingsToShift = this._treeSet.getSiblingsInVerticalDirection(node, node.getFreeDisplacement().y);
var last = node; var last = node;
siblingsToShift.forEach(function (sibling) { siblingsToShift.each(function (sibling) {
var overlappingOccurs = shiftedBranches.some(function (shiftedBranch) { var overlappingOccurs = shiftedBranches.some(function (shiftedBranch) {
return this._branchesOverlap(shiftedBranch, sibling, heightById); return this._branchesOverlap(shiftedBranch, sibling, heightById);
}, this); }, this);
@ -209,7 +209,7 @@ mindplot.layout.OriginalLayout = new Class({
return !shiftedBranches.contains(branch); return !shiftedBranches.contains(branch);
}); });
branchesToShift.forEach(function (branch) { branchesToShift.each(function (branch) {
var bAmount = node.getFreeDisplacement().y; var bAmount = node.getFreeDisplacement().y;
this._treeSet.shiftBranchPosition(branch, 0, bAmount); this._treeSet.shiftBranchPosition(branch, 0, bAmount);
shiftedBranches.push(branch); shiftedBranches.push(branch);

View File

@ -240,7 +240,7 @@ mindplot.layout.RootedTreeSet = new Class({
var yOffset = oldPos.y - position.y; var yOffset = oldPos.y - position.y;
var children = this.getChildren(node); var children = this.getChildren(node);
children.forEach(function (child) { children.each(function (child) {
this.shiftBranchPosition(child, xOffset, yOffset); this.shiftBranchPosition(child, xOffset, yOffset);
}.bind(this)); }.bind(this));
@ -251,7 +251,7 @@ mindplot.layout.RootedTreeSet = new Class({
node.setPosition({x:position.x + xOffset, y:position.y + yOffset}); node.setPosition({x:position.x + xOffset, y:position.y + yOffset});
var children = this.getChildren(node); var children = this.getChildren(node);
children.forEach(function (child) { children.each(function (child) {
this.shiftBranchPosition(child, xOffset, yOffset); this.shiftBranchPosition(child, xOffset, yOffset);
}.bind(this)); }.bind(this));
}, },

View File

@ -133,7 +133,7 @@ mindplot.layout.SymmetricSorter = new Class({
// Compute the center of the branch ... // Compute the center of the branch ...
var totalHeight = 0; var totalHeight = 0;
heights.forEach(function(elem) { heights.each(function(elem) {
totalHeight += elem.height; totalHeight += elem.height;
}); });
var ysum = totalHeight / 2; var ysum = totalHeight / 2;

View File

@ -135,7 +135,7 @@ mindplot.model.IMindmap = new Class({
// Then the rest of the branches ... // Then the rest of the branches ...
var sbranchs = source.getBranches(); var sbranchs = source.getBranches();
sbranchs.forEach(function(snode) { sbranchs.each(function(snode) {
var tnode = target.createNode(snode.getType(), snode.getId()); var tnode = target.createNode(snode.getType(), snode.getId());
snode.copyTo(tnode); snode.copyTo(tnode);
target.addBranch(tnode); target.addBranch(tnode);

View File

@ -213,7 +213,7 @@ mindplot.model.INodeModel = new Class({
var source = this; var source = this;
// Copy properties ... // Copy properties ...
var keys = source.getPropertiesKeys(); var keys = source.getPropertiesKeys();
keys.forEach(function(key) { keys.each(function(key) {
var value = source.getProperty(key); var value = source.getProperty(key);
target.putProperty(key, value); target.putProperty(key, value);
}); });
@ -222,7 +222,7 @@ mindplot.model.INodeModel = new Class({
var children = this.getChildren(); var children = this.getChildren();
var tmindmap = target.getMindmap(); var tmindmap = target.getMindmap();
children.forEach(function(snode) { children.each(function(snode) {
var tnode = tmindmap.createNode(snode.getType(), snode.getId()); var tnode = tmindmap.createNode(snode.getType(), snode.getId());
snode.copyTo(tnode); snode.copyTo(tnode);
target.appendChild(tnode); target.appendChild(tnode);
@ -278,10 +278,10 @@ mindplot.model.INodeModel = new Class({
var children = this.getChildren(); var children = this.getChildren();
if (children.length > 0) { if (children.length > 0) {
result = result + ", children: {(size:" + children.length; result = result + ", children: {(size:" + children.length;
children.forEach(function(node) { children.each(function(node) {
result = result + "=> ("; result = result + "=> (";
var keys = node.getPropertiesKeys(); var keys = node.getPropertiesKeys();
keys.forEach(function(key) { keys.each(function(key) {
var value = node.getProperty(key); var value = node.getProperty(key);
result = result + key + ":" + value + ","; result = result + key + ":" + value + ",";
}); });

View File

@ -25,7 +25,7 @@ mindplot.util.FadeEffect = new Class({
this.addEvent('complete', function() { this.addEvent('complete', function() {
this._element.forEach(function(elem) { this._element.each(function(elem) {
if(elem){ if(elem){
elem.setVisibility(isVisible); elem.setVisibility(isVisible);
} }
@ -39,7 +39,7 @@ mindplot.util.FadeEffect = new Class({
}, },
set: function(now) { set: function(now) {
this._element.forEach(function(elem) { this._element.each(function(elem) {
if(elem){ if(elem){
elem.setOpacity(now); elem.setOpacity(now);
} }

View File

@ -63,7 +63,7 @@ mindplot.widget.ColorPalettePanel = new Class({
// Register on toolbar elements ... // Register on toolbar elements ...
var colorCells = content.getElements('div[class=palette-colorswatch]'); var colorCells = content.getElements('div[class=palette-colorswatch]');
var model = this.getModel(); var model = this.getModel();
colorCells.forEach(function(elem) { colorCells.each(function(elem) {
elem.addEvent('click', function() { elem.addEvent('click', function() {
var color = elem.getStyle("background-color"); var color = elem.getStyle("background-color");
model.setValue(color); model.setValue(color);
@ -79,7 +79,7 @@ mindplot.widget.ColorPalettePanel = new Class({
// Clear selected cell based on the color ... // Clear selected cell based on the color ...
var tdCells = panelElem.getElements("td[class='palette-cell palette-cell-selected']"); var tdCells = panelElem.getElements("td[class='palette-cell palette-cell-selected']");
tdCells.forEach(function(elem) { tdCells.each(function(elem) {
elem.className = 'palette-cell'; elem.className = 'palette-cell';
}); });
@ -87,7 +87,7 @@ mindplot.widget.ColorPalettePanel = new Class({
var colorCells = panelElem.getElements('div[class=palette-colorswatch]'); var colorCells = panelElem.getElements('div[class=palette-colorswatch]');
var model = this.getModel(); var model = this.getModel();
var modelValue = model.getValue(); var modelValue = model.getValue();
colorCells.forEach(function(elem) { colorCells.each(function(elem) {
var color = elem.getStyle("background-color"); var color = elem.getStyle("background-color");
if (modelValue == color) { if (modelValue == color) {
elem.parentNode.className = 'palette-cell palette-cell-selected'; elem.parentNode.className = 'palette-cell palette-cell-selected';

View File

@ -29,7 +29,7 @@ mindplot.widget.IMenu = new Class({
}, },
clear:function () { clear:function () {
this._toolbarElems.forEach(function (item) { this._toolbarElems.each(function (item) {
item.hide(); item.hide();
}); });
}, },

View File

@ -26,7 +26,7 @@ mindplot.widget.ListToolbarPanel = new Class({
_initPanel: function () { _initPanel: function () {
// Register on toolbar elements ... // Register on toolbar elements ...
var menuElems = this.getPanelElem().getElements('div'); var menuElems = this.getPanelElem().getElements('div');
menuElems.forEach(function(elem) { menuElems.each(function(elem) {
elem.addEvent('click', function(event) { elem.addEvent('click', function(event) {
event.stopPropagation(); event.stopPropagation();
this.hide(); this.hide();
@ -41,7 +41,7 @@ mindplot.widget.ListToolbarPanel = new Class({
var panelElem = this.getPanelElem(); var panelElem = this.getPanelElem();
var menuElems = panelElem.getElements('div'); var menuElems = panelElem.getElements('div');
var value = this.getModel().getValue(); var value = this.getModel().getValue();
menuElems.forEach(function(elem) { menuElems.each(function(elem) {
var elemValue = $defined(elem.getAttribute('model')) ? elem.getAttribute('model') : elem.id; var elemValue = $defined(elem.getAttribute('model')) ? elem.getAttribute('model') : elem.id;
$assert(elemValue,"elemValue can not be null"); $assert(elemValue,"elemValue can not be null");
if (elemValue == value) if (elemValue == value)

View File

@ -438,7 +438,7 @@ mindplot.widget.Menu = new Class({
_registerEvents:function (designer) { _registerEvents:function (designer) {
// Register on close events ... // Register on close events ...
this._toolbarElems.forEach(function (elem) { this._toolbarElems.each(function (elem) {
elem.addEvent('show', function () { elem.addEvent('show', function () {
this.clear() this.clear()
}.bind(this)); }.bind(this));
@ -448,7 +448,7 @@ mindplot.widget.Menu = new Class({
var topics = designer.getModel().filterSelectedTopics(); var topics = designer.getModel().filterSelectedTopics();
var rels = designer.getModel().filterSelectedRelationships(); var rels = designer.getModel().filterSelectedRelationships();
this._toolbarElems.forEach(function (button) { this._toolbarElems.each(function (button) {
var disable = false; var disable = false;
if (button.isTopicAction() && button.isRelAction()) { if (button.isTopicAction() && button.isRelAction()) {
disable = rels.length == 0 && topics.length == 0; disable = rels.length == 0 && topics.length == 0;
@ -474,7 +474,7 @@ mindplot.widget.Menu = new Class({
var topics = designer.getModel().filterSelectedTopics(); var topics = designer.getModel().filterSelectedTopics();
var rels = designer.getModel().filterSelectedRelationships(); var rels = designer.getModel().filterSelectedRelationships();
this._toolbarElems.forEach(function (button) { this._toolbarElems.each(function (button) {
if (button.isTopicAction() && topics.length > 0) { if (button.isTopicAction() && topics.length > 0) {
button.enable(); button.enable();
} }

View File

@ -443,7 +443,7 @@ mindplot.layout.FreeTestSuite = new Class({
} }
var treeSet = manager._treeSet; var treeSet = manager._treeSet;
treeSet._rootNodes.forEach(function(rootNode) { treeSet._rootNodes.each(function(rootNode) {
var heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode); var heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode);
this._assertBranchCollision(treeSet, rootNode, heightById); this._assertBranchCollision(treeSet, rootNode, heightById);
}, this); }, this);
@ -453,7 +453,7 @@ mindplot.layout.FreeTestSuite = new Class({
var children = treeSet.getChildren(node); var children = treeSet.getChildren(node);
var childOfRootNode = treeSet._rootNodes.contains(node); var childOfRootNode = treeSet._rootNodes.contains(node);
children.forEach(function(child) { children.each(function(child) {
var height = heightById[child.getId()]; var height = heightById[child.getId()];
var siblings = treeSet.getSiblings(child); var siblings = treeSet.getSiblings(child);
if (childOfRootNode) { if (childOfRootNode) {
@ -461,12 +461,12 @@ mindplot.layout.FreeTestSuite = new Class({
return (child.getOrder() % 2) == (sibling.getOrder() % 2); return (child.getOrder() % 2) == (sibling.getOrder() % 2);
}) })
} }
siblings.forEach(function(sibling) { siblings.each(function(sibling) {
this._branchesOverlap(child, sibling, heightById); this._branchesOverlap(child, sibling, heightById);
}, this); }, this);
}, this); }, this);
children.forEach(function(child) { children.each(function(child) {
this._assertBranchCollision(treeSet, child, heightById); this._assertBranchCollision(treeSet, child, heightById);
}, this) }, this)
}, },