Fix multple node selection in toolbar.

This commit is contained in:
Paulo Veiga
2011-08-09 09:03:46 -03:00
parent 6843323d2f
commit fb5f22aaac
6 changed files with 61 additions and 111 deletions

View File

@@ -101,7 +101,7 @@ mindplot.widget.ColorPalettePanel = new Class({
},
show : function() {
if (!this.isVisible()) {
if (!this.isVisible()) {
this.parent();
var panelElem = this._getPanelElem();
@@ -115,9 +115,10 @@ mindplot.widget.ColorPalettePanel = new Class({
// Mark the cell as selected ...
var colorCells = panelElem.getElements('div[class=palette-colorswatch]');
var model = this.getModel();
var modelValue = model.getValue();
colorCells.forEach(function(elem) {
var color = elem.getStyle("background-color");
if (model.getValue() == color) {
if (modelValue == color) {
elem.parentNode.className = 'palette-cell palette-cell-selected';
}
});

View File

@@ -43,9 +43,16 @@ mindplot.widget.Menu = new Class({
var fontFamilyModel = {
getValue: function() {
var nodes = designer.getSelectedNodes();
if (nodes.length == 1) {
return nodes[0].getFontFamily();
var result = null;
for (var i=0; i < nodes.length; i++) {
var fontFamily = nodes[i].getFontFamily();
if (result != null && result != fontFamily) {
result = null;
break;
}
result = fontFamily;
}
return result;
},
setValue: function(value) {
@@ -58,9 +65,16 @@ mindplot.widget.Menu = new Class({
var fontSizeModel = {
getValue: function() {
var nodes = designer.getSelectedNodes();
if (nodes.length == 1) {
return nodes[0].getFontSize();
var result = null;
for (var i=0; i < nodes.length; i++) {
var fontSize = nodes[i].getFontSize();
if (result != null && result != fontSize) {
result = null;
break;
}
result = fontSize;
}
return result;
},
setValue: function(value) {
designer.setFontSize2SelectedNode(value);
@@ -71,9 +85,16 @@ mindplot.widget.Menu = new Class({
var topicShapeModel = {
getValue: function() {
var nodes = designer.getSelectedNodes();
if (nodes.length == 1) {
return nodes[0].getShapeType();
var result = null;
for (var i=0; i < nodes.length; i++) {
var shapeType = nodes[i].getShapeType();
if (result != null && result != shapeType) {
result = null;
break;
}
result = shapeType;
}
return result;
},
setValue: function(value) {
designer.setShape2SelectedNode(value);
@@ -97,10 +118,16 @@ mindplot.widget.Menu = new Class({
{
getValue : function() {
var nodes = designer.getSelectedNodes();
if (nodes.length == 1) {
return nodes[0].getBackgroundColor();
var result = null;
for (var i=0; i < nodes.length; i++) {
var color = nodes[i].getBackgroundColor();
if (result != null && result != color) {
result = null;
break;
}
result = color;
}
return null;
return result;
},
setValue : function (hex) {
designer.setBackColor2SelectedNode(hex);
@@ -113,9 +140,16 @@ mindplot.widget.Menu = new Class({
{
getValue : function() {
var nodes = designer.getSelectedNodes();
if (nodes.length == 1) {
return nodes[0].getBorderColor();
var result = null;
for (var i=0; i < nodes.length; i++) {
var color = nodes[i].getBorderColor();
if (result != null && result != color) {
result = null;
break;
}
result = color;
}
return result;
},
setValue : function (hex) {
designer.setBorderColor2SelectedNode(hex);
@@ -127,10 +161,17 @@ mindplot.widget.Menu = new Class({
var fontColorModel =
{
getValue : function() {
var result = null;
var nodes = designer.getSelectedNodes();
if (nodes.length == 1) {
return nodes[0].getFontColor();
for (var i=0; i < nodes.length; i++) {
var color = nodes[i].getFontColor();
if (result != null && result != color) {
result = null;
break;
}
result = color;
}
return result;
},
setValue : function (hex) {
designer.setFontColor2SelectedNode(hex);