Refactor menu.
This commit is contained in:
@@ -156,6 +156,18 @@
|
||||
files="layout/FreeMindLayoutManager.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="layout/LayoutManagerFactory.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="widget/IconPanel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="widget/ToolbarPanel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="widget/FontFamilyPanel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="widget/FontSizePanel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="widget/TopicShapePanel.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="widget/Menu.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="footer.js"/>
|
||||
</concat>
|
||||
|
||||
|
@@ -681,7 +681,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
}
|
||||
},
|
||||
|
||||
addImage2SelectedNode : function(iconType) {
|
||||
addIconType2SelectedNode : function(iconType) {
|
||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||
var topicsIds = validSelectedObjects.nodes;
|
||||
if (topicsIds.length > 0) {
|
||||
|
@@ -25,4 +25,5 @@
|
||||
var mindplot = {};
|
||||
mindplot.util = {};
|
||||
mindplot.commands = {};
|
||||
mindplot.layout = {};
|
||||
mindplot.layout = {};
|
||||
mindplot.widget = {};
|
37
mindplot/src/main/javascript/widget/FontFamilyPanel.js
Normal file
37
mindplot/src/main/javascript/widget/FontFamilyPanel.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.widget.FontFamilyPanel = new Class({
|
||||
Extends : mindplot.widget.ToolbarPanel,
|
||||
initialize : function(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
buildPanel: function() {
|
||||
|
||||
var content = new Element("div", {'class':'toolbarPanel','id':'fontFamilyPanel'});
|
||||
content.innerHTML = '' +
|
||||
'<div id="times" model="Times" class="toolbarPanelLink" style="font-family:times;">Times</div>' +
|
||||
'<div id="arial" model="Arial" style="font-family:arial;">Arial</div>' +
|
||||
'<div id="tahoma" model="Tahoma" style="font-family:tahoma;">Tahoma</div>' +
|
||||
'<div id="verdana" model="Verdana" style="font-family:verdana;">Verdana</div>';
|
||||
|
||||
return content;
|
||||
|
||||
}
|
||||
});
|
37
mindplot/src/main/javascript/widget/FontSizePanel.js
Normal file
37
mindplot/src/main/javascript/widget/FontSizePanel.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.widget.FontSizePanel = new Class({
|
||||
Extends : mindplot.widget.ToolbarPanel,
|
||||
initialize : function(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
buildPanel: function() {
|
||||
|
||||
var content = new Element("div", {'class':'toolbarPanel','id':'fontSizePanel'});
|
||||
content.innerHTML = '' +
|
||||
'<div id="small" model="6" style="font-size:8px">Small</div>' +
|
||||
'<div id="normal" model="8" style="font-size:12px">Normal</div>' +
|
||||
'<div id="large" model="10" style="font-size:15px">Large</div>' +
|
||||
'<div id="huge" model="15" style="font-size:24px">Huge</div>';
|
||||
|
||||
return content;
|
||||
|
||||
}
|
||||
});
|
141
mindplot/src/main/javascript/widget/IconPanel.js
Normal file
141
mindplot/src/main/javascript/widget/IconPanel.js
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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.widget.IconPanel = new Class({
|
||||
Implements:[Options,Events],
|
||||
options:{
|
||||
width:253,
|
||||
initialWidth:0,
|
||||
height:200,
|
||||
panel:null,
|
||||
onStart:Class.empty,
|
||||
state:'close'
|
||||
},
|
||||
|
||||
initialize:function(buttonId, model) {
|
||||
this._buttonId = buttonId;
|
||||
this._model = model;
|
||||
|
||||
this.options.content = this._build();
|
||||
this.init();
|
||||
|
||||
},
|
||||
|
||||
init:function() {
|
||||
var panel = new Element('div');
|
||||
var buttonElem = $(this._buttonId);
|
||||
|
||||
var coord = buttonElem.getCoordinates();
|
||||
var top = buttonElem.getTop() + coord.height + 2;
|
||||
var left = buttonElem.getLeft();
|
||||
|
||||
panel.setStyles({
|
||||
width:this.options.initialWidth,
|
||||
height:0,position:'absolute',
|
||||
top:top,
|
||||
left:left,
|
||||
background:'#e5e5e5',
|
||||
border:'1px solid #BBB4D6',
|
||||
zIndex:20,
|
||||
overflow:'hidden'}
|
||||
);
|
||||
|
||||
this.options.panel = panel;
|
||||
this.options.content.inject(panel);
|
||||
|
||||
this.options.content.addEvent('click', function() {
|
||||
this.hide();
|
||||
}.bind(this));
|
||||
|
||||
panel.setStyle('opacity', 0);
|
||||
panel.inject($(document.body));
|
||||
this.registerOpenPanel();
|
||||
},
|
||||
|
||||
show:function() {
|
||||
this.fireEvent("show");
|
||||
if (this.options.state == 'close') {
|
||||
if (!$defined(this.options.panel)) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
var panel = this.options.panel;
|
||||
panel.setStyles({
|
||||
border: '1px solid #636163',
|
||||
opacity:100,
|
||||
height:this.options.height,
|
||||
width:this.options.width
|
||||
});
|
||||
this.fireEvent('onStart');
|
||||
this.registerClosePanel();
|
||||
this.options.state = 'open';
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
hide:function() {
|
||||
if (this.options.state == 'open') {
|
||||
// Magic, disappear effect ;)
|
||||
this.options.panel.setStyles({border: '1px solid transparent', opacity:0});
|
||||
this.registerOpenPanel();
|
||||
this.options.state = 'close';
|
||||
}
|
||||
},
|
||||
|
||||
registerOpenPanel:function() {
|
||||
$(this._buttonId).removeEvents('click');
|
||||
$(this._buttonId).addEvent('click', function() {
|
||||
this.show();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
registerClosePanel:function() {
|
||||
$(this._buttonId).removeEvents('click');
|
||||
$(this._buttonId).addEvent('click', function() {
|
||||
this.hide();
|
||||
}.bind(this));
|
||||
} ,
|
||||
|
||||
_build : function() {
|
||||
var content = new Element('div').setStyles({width:253,height:200,padding:5});
|
||||
var count = 0;
|
||||
for (var i = 0; i < mindplot.ImageIcon.prototype.ICON_FAMILIES.length; i = i + 1) {
|
||||
var familyIcons = mindplot.ImageIcon.prototype.ICON_FAMILIES[i].icons;
|
||||
for (var j = 0; j < familyIcons.length; j = j + 1) {
|
||||
// Separate icons by line ...
|
||||
var familyContent;
|
||||
if ((count % 12) == 0) {
|
||||
familyContent = new Element('div').inject(content);
|
||||
}
|
||||
|
||||
var iconId = familyIcons[j];
|
||||
var img = new Element('img').setStyles({width:16,height:16,padding:"0px 2px"}).inject(familyContent);
|
||||
img.id = iconId;
|
||||
img.src = mindplot.ImageIcon.prototype._getImageUrl(iconId);
|
||||
|
||||
img.addEvent('click', function() {
|
||||
this._model.setValue(img.id);
|
||||
}.bind(this));
|
||||
|
||||
count = count + 1;
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
});
|
150
mindplot/src/main/javascript/widget/Menu.js
Normal file
150
mindplot/src/main/javascript/widget/Menu.js
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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.widget.Menu = new Class({
|
||||
initialize : function(designer) {
|
||||
this._designer = designer;
|
||||
this._toolbarElems = [];
|
||||
this._colorPickers = [];
|
||||
|
||||
var fontFamilyModel = {
|
||||
getValue: function() {
|
||||
var nodes = designer.getSelectedNodes();
|
||||
var length = nodes.length;
|
||||
if (length == 1) {
|
||||
return nodes[0].getFontFamily();
|
||||
}
|
||||
},
|
||||
|
||||
setValue: function(value) {
|
||||
designer.setFont2SelectedNode(value);
|
||||
|
||||
}
|
||||
};
|
||||
var fontFamilyPanel = new mindplot.widget.FontFamilyPanel("fontFamily", fontFamilyModel);
|
||||
fontFamilyPanel.addEvent('show',function(){this.clear()}.bind(this));
|
||||
this._toolbarElems.push(fontFamilyPanel);
|
||||
|
||||
var fontSizeModel = {
|
||||
getValue: function() {
|
||||
var nodes = designer.getSelectedNodes();
|
||||
var length = nodes.length;
|
||||
if (length == 1) {
|
||||
return nodes[0].getFontSize();
|
||||
}
|
||||
},
|
||||
setValue: function(value) {
|
||||
designer.setFontSize2SelectedNode(value);
|
||||
}
|
||||
};
|
||||
var fontSizePanel = new mindplot.widget.FontSizePanel("fontSize", fontSizeModel);
|
||||
fontSizePanel.addEvent('show',function(){this.clear()}.bind(this));
|
||||
this._toolbarElems.push(fontSizePanel);
|
||||
|
||||
var topicShapeModel = {
|
||||
getValue: function() {
|
||||
var nodes = designer.getSelectedNodes();
|
||||
var length = nodes.length;
|
||||
if (length == 1) {
|
||||
return nodes[0].getShapeType();
|
||||
}
|
||||
},
|
||||
setValue: function(value) {
|
||||
designer.setShape2SelectedNode(value);
|
||||
}
|
||||
};
|
||||
var topicShapePanel = new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel);
|
||||
topicShapePanel.addEvent('show',function(){this.clear()}.bind(this));
|
||||
this._toolbarElems.push(topicShapePanel);
|
||||
|
||||
// Create icon panel dialog ...
|
||||
var topicIconModel = {
|
||||
getValue: function() {
|
||||
return null;
|
||||
},
|
||||
setValue: function(value) {
|
||||
designer.addIconType2SelectedNode(value);
|
||||
}
|
||||
};
|
||||
var iconPanel = new mindplot.widget.IconPanel('topicIcon', topicIconModel);
|
||||
iconPanel.addEvent('show',function(){this.clear()}.bind(this));
|
||||
this._toolbarElems.push(iconPanel);
|
||||
|
||||
|
||||
var topicColorPicker = new MooRainbow('topicColor', {
|
||||
id: 'topicColor',
|
||||
imgPath: '../images/',
|
||||
startColor: [255, 255, 255],
|
||||
onInit: function() {
|
||||
this.clear();
|
||||
}.bind(this),
|
||||
|
||||
onChange: function(color) {
|
||||
designer.setBackColor2SelectedNode(color.hex);
|
||||
},
|
||||
onComplete: function() {
|
||||
this.clear();
|
||||
}.bind(this)
|
||||
});
|
||||
this._colorPickers.push(topicColorPicker);
|
||||
|
||||
var borderColorPicker = new MooRainbow('topicBorder', {
|
||||
id: 'topicBorder',
|
||||
imgPath: '../images/',
|
||||
startColor: [255, 255, 255],
|
||||
onInit: function() {
|
||||
this.clear();
|
||||
}.bind(this),
|
||||
onChange: function(color) {
|
||||
designer.setBorderColor2SelectedNode(color.hex);
|
||||
},
|
||||
onComplete: function() {
|
||||
this.clear();
|
||||
}.bind(this)
|
||||
|
||||
});
|
||||
this._colorPickers.push(borderColorPicker);
|
||||
|
||||
var fontColorPicker = new MooRainbow('fontColor', {
|
||||
id: 'fontColor',
|
||||
imgPath: '../images/',
|
||||
startColor: [255, 255, 255],
|
||||
onInit: function() {
|
||||
this.clear();
|
||||
}.bind(this),
|
||||
onChange: function(color) {
|
||||
designer.setFontColor2SelectedNode(color.hex);
|
||||
},
|
||||
onComplete: function() {
|
||||
this.clear();
|
||||
}.bind(this)
|
||||
});
|
||||
this._colorPickers.push(fontColorPicker);
|
||||
},
|
||||
|
||||
clear : function() {
|
||||
this._toolbarElems.forEach(function(elem) {
|
||||
elem.hide();
|
||||
});
|
||||
|
||||
this._colorPickers.forEach(function(elem) {
|
||||
$clear(elem);
|
||||
elem.hide();
|
||||
});
|
||||
}
|
||||
});
|
89
mindplot/src/main/javascript/widget/ToolbarPanel.js
Normal file
89
mindplot/src/main/javascript/widget/ToolbarPanel.js
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.widget.ToolbarPanel = new Class({
|
||||
Implements:[Events],
|
||||
initialize : function(buttonId, model) {
|
||||
$assert(buttonId, "buttonId can not be null");
|
||||
$assert(model, "model can not be null");
|
||||
this._model = model;
|
||||
this._panelId = this.initPanel(buttonId);
|
||||
},
|
||||
|
||||
buildPanel : function() {
|
||||
throw "Method must be implemented";
|
||||
}.protect(),
|
||||
|
||||
initPanel: function (buttonId) {
|
||||
$assert(buttonId, "buttonId can not be null");
|
||||
|
||||
var panelElem = this.buildPanel();
|
||||
var buttonElem = $(buttonId);
|
||||
|
||||
// Add panel content ..
|
||||
panelElem.setStyle('display', 'none');
|
||||
panelElem.inject(buttonElem);
|
||||
|
||||
// Register on toolbar elements ...
|
||||
var menuElems = panelElem.getElements('div');
|
||||
menuElems.forEach(function(elem) {
|
||||
elem.addEvent('click', function() {
|
||||
var value = $defined(elem.getAttribute('model')) ? elem.getAttribute('model') : elem.id;
|
||||
this._model.setValue(value);
|
||||
this.hide();
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
// Font family event handling ....
|
||||
buttonElem.addEvent('click', function() {
|
||||
|
||||
// Is the panel being displayed ?
|
||||
if (this.isVisible()) {
|
||||
this.hide();
|
||||
} else {
|
||||
this.show();
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
return panelElem.id;
|
||||
},
|
||||
|
||||
show : function() {
|
||||
this.fireEvent('show');
|
||||
|
||||
var menuElems = $(this._panelId).getElements('div');
|
||||
var value = this._model.getValue();
|
||||
menuElems.forEach(function(elem) {
|
||||
var elemValue = $defined(elem.getAttribute('model')) ? elem.getAttribute('model') : elem.id;
|
||||
if (elemValue == value)
|
||||
elem.className = "toolbarPanelLinkSelectedLink";
|
||||
else
|
||||
elem.className = "toolbarPanelLink";
|
||||
});
|
||||
$(this._panelId).setStyle('display', 'block');
|
||||
|
||||
},
|
||||
|
||||
hide : function() {
|
||||
$(this._panelId).setStyle('display', 'none');
|
||||
},
|
||||
|
||||
isVisible : function() {
|
||||
return $(this._panelId).getStyle('display') == 'block';
|
||||
}
|
||||
});
|
37
mindplot/src/main/javascript/widget/TopicShapePanel.js
Normal file
37
mindplot/src/main/javascript/widget/TopicShapePanel.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.widget.TopicShapePanel = new Class({
|
||||
Extends : mindplot.widget.ToolbarPanel,
|
||||
initialize : function(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
buildPanel: function() {
|
||||
|
||||
var content = new Element("div", {'class':'toolbarPanel','id':'topicShapePanel'});
|
||||
content.innerHTML = '' +
|
||||
'<div id="rectagle" model="rectagle"><img src="../images/shape-rectangle.png" alt="Rectangle" width="40" height="25"></div>' +
|
||||
'<div id="rounded_rectagle" model="rounded rectagle" ><img src="../images/shape-rectangle-rounded.png"alt="Rounded Rectangle" width="40" height="25"></div>' +
|
||||
'<div id="line" model="line"><img src="../images/shape-line.png" alt="Line" width="40" height="7"></div>' +
|
||||
'<div id="elipse" model="elipse" class="toolbarPanelLink"><img src="../images/shape-elipse.png" alt="Elipse" width="40" height="25"></div>';
|
||||
|
||||
return content;
|
||||
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user