Add publish map on editor.

This commit is contained in:
Paulo Gustavo Veiga
2012-05-27 18:15:46 -03:00
parent 2b4953ea11
commit 5d1399017f
27 changed files with 343 additions and 335 deletions

View File

@@ -96,11 +96,11 @@ mindplot.ControlPoint = new Class({
var pos = screen.getWorkspaceMousePosition(event);
var topic = null;
if (point == 0) {
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getSourceTopic(), pos);
var cords = mindplot.util.Shape.calculateRelationShipPointCoordinates(this._line.getSourceTopic(), pos);
this._line.setFrom(cords.x, cords.y);
this._line.setSrcControlPoint(new core.Point(pos.x - cords.x, pos.y - cords.y));
} else {
var cords = core.Utils.calculateRelationShipPointCoordinates(this._line.getTargetTopic(), pos);
var cords = mindplot.util.Shape.calculateRelationShipPointCoordinates(this._line.getTargetTopic(), pos);
this._line.setTo(cords.x, cords.y);
this._line.setDestControlPoint(new core.Point(pos.x - cords.x, pos.y - cords.y));
}

View File

@@ -51,7 +51,9 @@ mindplot.LocalStorageManager = new Class({
}
}
return core.Utils.createDocumentFromText(xml);
var parser = new DOMParser();
return parser.parseFromString(xml, "text/xml");
}
}
);

View File

@@ -60,7 +60,7 @@ mindplot.RelationshipLine = new Class({
this._line2d.setStroke(2);
var ctrlPoints = this._line2d.getControlPoints();
if (!this._line2d.isDestControlPointCustom() && !this._line2d.isSrcControlPointCustom()) {
var defaultPoints = core.Utils.calculateDefaultControlPoints(sourcePosition, targetPosition);
var defaultPoints = mindplot.util.Shape.calculateDefaultControlPoints(sourcePosition, targetPosition);
ctrlPoints[0].x = defaultPoints[0].x;
ctrlPoints[0].y = defaultPoints[0].y;
ctrlPoints[1].x = defaultPoints[1].x;
@@ -73,8 +73,8 @@ mindplot.RelationshipLine = new Class({
var tpoint = new core.Point();
tpoint.x = parseInt(ctrlPoints[1].x) + parseInt(targetPosition.x);
tpoint.y = parseInt(ctrlPoints[1].y) + parseInt(targetPosition.y);
sPos = core.Utils.calculateRelationShipPointCoordinates(sourceTopic, spoint);
tPos = core.Utils.calculateRelationShipPointCoordinates(targetTopic, tpoint);
sPos = mindplot.util.Shape.calculateRelationShipPointCoordinates(sourceTopic, spoint);
tPos = mindplot.util.Shape.calculateRelationShipPointCoordinates(targetTopic, tpoint);
line2d.setFrom(sPos.x, sPos.y);
line2d.setTo(tPos.x, tPos.y);

View File

@@ -42,11 +42,10 @@ var MooDialog = new Class({
options = this.options;
var wrapper = this.wrapper = new Element('div.' + options['class'].replace(' ', '.')).inject(options.inject);
this.content = new Element('div.content').inject(wrapper);
if (options.title){
this.title = new Element('div.title').set('text', options.title).inject(wrapper);
wrapper.addClass('MooDialogTitle');
// this.title.addClass('MooDialogTitle');
}
if (options.closeButton){
@@ -54,6 +53,7 @@ var MooDialog = new Class({
events: {click: this.close.bind(this)}
}).inject(wrapper);
}
this.content = new Element('div.content').inject(wrapper);
/*<ie6>*/// IE 6 scroll

View File

@@ -41,6 +41,57 @@ mindplot.util.Shape =
}
return result;
},
calculateRelationShipPointCoordinates : function(topic, controlPoint) {
var size = topic.getSize();
var position = topic.getPosition();
var m = (position.y - controlPoint.y) / (position.x - controlPoint.x);
var y,x;
var gap = 5;
if (controlPoint.y > position.y + (size.height / 2)) {
y = position.y + (size.height / 2) + gap;
x = position.x - ((position.y - y) / m);
if (x > position.x + (size.width / 2)) {
x = position.x + (size.width / 2);
} else if (x < position.x - (size.width / 2)) {
x = position.x - (size.width / 2);
}
} else if (controlPoint.y < position.y - (size.height / 2)) {
y = position.y - (size.height / 2) - gap;
x = position.x - ((position.y - y) / m);
if (x > position.x + (size.width / 2)) {
x = position.x + (size.width / 2);
} else if (x < position.x - (size.width / 2)) {
x = position.x - (size.width / 2);
}
} else if (controlPoint.x < (position.x - size.width / 2)) {
x = position.x - (size.width / 2) - gap;
y = position.y - (m * (position.x - x));
} else {
x = position.x + (size.width / 2) + gap;
y = position.y - (m * (position.x - x));
}
return new core.Point(x, y);
},
calculateDefaultControlPoints : function(srcPos, tarPos) {
var y = srcPos.y - tarPos.y;
var x = srcPos.x - tarPos.x;
var m = y / x;
var l = Math.sqrt(y * y + x * x) / 3;
var fix = 1;
if (srcPos.x > tarPos.x) {
fix = -1;
}
var x1 = srcPos.x + Math.sqrt(l * l / (1 + (m * m))) * fix;
var y1 = m * (x1 - srcPos.x) + srcPos.y;
var x2 = tarPos.x + Math.sqrt(l * l / (1 + (m * m))) * fix * -1;
var y2 = m * (x2 - tarPos.x) + tarPos.y;
return [new core.Point(-srcPos.x + x1, -srcPos.y + y1),new core.Point(-tarPos.x + x2, -tarPos.y + y2)];
}
};

View File

@@ -61,7 +61,7 @@ mindplot.widget.LinkIconTooltip = new Class({
var imgContainer = new Element('div');
imgContainer.setStyles({
width: '100%',
textAlign: 'center',
textAlign: 'right',
'padding-bottom':'5px',
'padding-top': '5px'
});

View File

@@ -193,7 +193,7 @@ mindplot.widget.Menu = new Class({
this._addButton('export', false, false, function() {
var reqDialog = new MooDialog.Request('c/map/' + mapId + '/export.htm', null,
{'class': 'exportModalDialog',
{'class': 'modalDialog exportModalDialog',
closeButton:true,
destroyOnClose:true,
title:'Export'
@@ -317,7 +317,7 @@ mindplot.widget.Menu = new Class({
if (tagElem) {
this._addButton('tagIt', false, false, function() {
var reqDialog = new MooDialog.Request('c/tags.htm?mapId=' + mapId, null,
{'class': 'tagItModalDialog',
{'class': 'modalDialog tagItModalDialog',
closeButton:true,
destroyOnClose:true,
title:'Tags'
@@ -335,7 +335,7 @@ mindplot.widget.Menu = new Class({
if (shareElem) {
this._addButton('shareIt', false, false, function() {
var reqDialog = new MooDialog.Request('c/mymaps.htm?action=collaborator&mapId=' + mapId, null,
{'class': 'shareItModalDialog',
{'class': 'modalDialog shareItModalDialog',
closeButton:true,
destroyOnClose:true,
title:'Share It'
@@ -354,8 +354,8 @@ mindplot.widget.Menu = new Class({
var publishElem = $('publishIt');
if (publishElem) {
this._addButton('publishIt', false, false, function() {
var reqDialog = new MooDialog.Request('c/publish.htm?mapId=' + mapId, null,
{'class': 'publishModalDialog',
var reqDialog = new MooDialog.Request('c/iframeWrapper.htm?url=c/maps/' + mapId + "/publishf.htm", null,
{'class': 'modalDialog publishModalDialog',
closeButton:true,
destroyOnClose:true,
title:'Publish'
@@ -365,6 +365,7 @@ mindplot.widget.Menu = new Class({
reqDialog.setContent('loading...');
}
});
MooDialog.Request.active = reqDialog;
});
this._registerTooltip('publishIt', "Publish");
@@ -375,7 +376,7 @@ mindplot.widget.Menu = new Class({
this._addButton('history', false, false, function() {
var reqDialog = new MooDialog.Request('c/history.htm?action=list&goToMindmapList&mapId=' + mapId, null,
{'class': 'historyModalDialog',
{'class': 'modalDialog historyModalDialog',
closeButton:true,
destroyOnClose:true,
title:'History'

View File

@@ -93,7 +93,7 @@ mindplot.widget.NoteEditor = new Class({
}.bind(this));
// Add buttons ...
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'right'});
// Create accept button ...
var okButton = new Element('input', {type:'submit', value:'Accept','class':'btn-primary'});
@@ -113,7 +113,6 @@ mindplot.widget.NoteEditor = new Class({
buttonContainer.inject(form);
}
// Create cancel button ...
var cButton = new Element('input', {type:'button', value:'Cancel','class':'btn-secondary'});
cButton.setStyle('margin', '5px');

View File

@@ -1,10 +1,11 @@
TestCase("Model Migration Tests",{
setUp:function(){
TestCase("Model Migration Tests", {
setUp:function() {
mapXml = '<map name="1"><topic central="true" text="test"><topic position="-127,-100" fontStyle="Verdana;;#038f39;;italic;" brColor="#db770b"><topic order="0"/><topic order="1"/><topic order="2"><topic order="0"/><topic order="1"/><topic order="2"/></topic></topic><topic position="-168,50" shape="line"><icon id="conn_disconnect"/><icon id="chart_curve"/></topic><topic position="166,-100" shape="elipse"><note text="this%20is%20a%20note"/><topic order="0"/><topic order="1"/><topic order="2"/></topic><topic position="173,0" shape="rectagle" bgColor="#f2a2b5"><link url="www.google.com"/></topic></topic><topic position="-391,-2" text="im alone"/></map>';
},
testModelMigration:function(){
ids=[];
var domDocument = core.Utils.createDocumentFromText(mapXml);
testModelMigration:function() {
ids = [];
var parser = new DOMParser();
var domDocument = parser.parseFromString(xml, "text/xml");
var betaSerializer = new mindplot.persistence.XMLSerializer_Beta();
var betaMap = betaSerializer.loadFromDom(domDocument);
@@ -22,31 +23,31 @@ TestCase("Model Migration Tests",{
//Assert same nodes recursively
//Since Id can change let's assume the order is the same
for(var i = 0; i<betaBranches.length; i++){
for (var i = 0; i < betaBranches.length; i++) {
var branch = betaBranches[i];
this._findAndCompareNodes(branch, branches[i]);
}
},
_findAndCompareNodes:function(betaNode, node){
_findAndCompareNodes:function(betaNode, node) {
this._compareNodes(betaNode, node);
//Assert same nodes recursively
//Since Id can change let's assume the order is the same
for(var i = 0; i<betaNode.getChildren().length; i++){
for (var i = 0; i < betaNode.getChildren().length; i++) {
var betaChild = betaNode.getChildren()[i];
var child = node.getChildren()[i];
this._findAndCompareNodes(betaChild, child);
}
},
_compareNodes:function(node1, node2){
_compareNodes:function(node1, node2) {
assertNotNull(node1);
assertNotNull(node2);
//In Pela Version every id is different
var pelaId = node2.getId();
assertTrue(ids[pelaId]==undefined);
assertTrue(ids[pelaId] == undefined);
ids.push(pelaId);
var children1 = node1.getChildren();
@@ -55,9 +56,9 @@ TestCase("Model Migration Tests",{
var position1 = node1.getPosition();
var position2 = node2.getPosition();
if(position1==null){
if (position1 == null) {
assertNull(position2);
}else{
} else {
assertEquals(position1.x, position2.x);
assertEquals(position1.y, position2.y);
}
@@ -69,13 +70,13 @@ TestCase("Model Migration Tests",{
assertEquals(node1.getSize().height, node2.getSize().height);
this._compareIcons(node1.getIcons(), node2.getIcons());
this._compareLinks(node1.getLinks(), node2.getLinks());
this._compareNotes(node1.getNotes(),node2.getNotes());
this._compareNotes(node1.getNotes(), node2.getNotes());
var order1 = node1.getOrder();
var order2 = node2.getOrder();
if(order1==null){
if (order1 == null) {
assertNull(order2);
}else{
} else {
assertEquals(order1, order2);
}
assertEquals(node1.getShapeType(), node2.getShapeType());
@@ -86,27 +87,27 @@ TestCase("Model Migration Tests",{
assertEquals(node1.getBorderColor(), node2.getBorderColor());
assertEquals(node1.getBackgroundColor(), node2.getBackgroundColor());
},
_compareLinks:function(links1, links2){
_compareLinks:function(links1, links2) {
assertEquals(links1.length, links2.length);
for(var i=0; i<links1.length; i++){
for (var i = 0; i < links1.length; i++) {
var link1 = links1[i];
var link2 = links2[i];
assertEquals(link1.getUrl(), link2.getUrl());
}
},
_compareIcons:function(icons1, icons2){
_compareIcons:function(icons1, icons2) {
assertEquals(icons1.length, icons2.length);
for(var i=0; i<icons1.length; i++){
for (var i = 0; i < icons1.length; i++) {
var icon1 = icons1[i];
var icon2 = icons2[i];
assertEquals(icon1.getIconType(), icon2.getIconType());
}
},
_compareNotes:function(notes1, notes2){
_compareNotes:function(notes1, notes2) {
assertEquals(notes1.length, notes2.length);
for(var i=0; i<notes1.length; i++){
for (var i = 0; i < notes1.length; i++) {
var note1 = notes1[i];
var note2 = notes2[i];
assertEquals(note1.getText(), note2.getText());