diff --git a/mindplot/pom.xml b/mindplot/pom.xml index 76286f05..aa13153d 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -19,8 +19,21 @@ 1.0-SNAPSHOT runtime + + com.google.jstestdriver + maven-jstestdriver-plugin + 1.2.2-SNAPSHOT + test + + + + jstd-maven-plugin google code repo + http://jstd-maven-plugin.googlecode.com/svn/maven2 + + + @@ -111,12 +124,28 @@ files="commands/AddRelationshipCommand.js"/> + + + + + + + + + + @@ -213,8 +242,14 @@ commands/AddRelationshipCommand-min.js commands/MoveControlPointCommand-min.js + layoutManagers/boards/Board-min.js + layoutManagers/boards/freeMindBoards/Board-min.js + layoutManagers/boards/freeMindBoards/Entry-min.js + layoutManagers/boards/freeMindBoards/CentralTopicBoard-min.js + layoutManagers/boards/freeMindBoards/MainTopicBoard-min.js layoutManagers/BaseLayoutManager-min.js layoutManagers/OriginalLayoutManager-min.js + layoutManagers/FreeMindLayoutManager-min.js layoutManagers/LayoutManagerFactory-min.js footer-min.js @@ -235,6 +270,33 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.4.2 + + true + + + + + com.google.jstestdriver + maven-jstestdriver-plugin + 1.2.2-SNAPSHOT + + + run-tests + test + + test + + + true + src/test/resources/jsTestDriver.conf + + + + diff --git a/mindplot/src/main/javascript/CentralTopicBoard.js b/mindplot/src/main/javascript/CentralTopicBoard.js index a0a42956..3439c4bd 100644 --- a/mindplot/src/main/javascript/CentralTopicBoard.js +++ b/mindplot/src/main/javascript/CentralTopicBoard.js @@ -25,7 +25,7 @@ mindplot.CentralTopicBoard = function(centralTopic, layoutManager) this._centralTopic = centralTopic; }; -objects.extend(mindplot.CentralTopicBoard, mindplot.TopicBoard); +objects.extend(mindplot.CentralTopicBoard, mindplot.Board); mindplot.CentralTopicBoard.prototype._getBoard = function(position) { diff --git a/mindplot/src/main/javascript/EditorOptions.js b/mindplot/src/main/javascript/EditorOptions.js index 96244c5f..076ba379 100644 --- a/mindplot/src/main/javascript/EditorOptions.js +++ b/mindplot/src/main/javascript/EditorOptions.js @@ -1,5 +1,5 @@ mindplot.EditorOptions = { LayoutManager:"OriginalLayout" -// NodeLayoutManager:"FreeLayout" + // LayoutManager:"FreeMindLayout" }; \ No newline at end of file diff --git a/mindplot/src/main/javascript/MainTopic.js b/mindplot/src/main/javascript/MainTopic.js index 855e59f1..cebae842 100644 --- a/mindplot/src/main/javascript/MainTopic.js +++ b/mindplot/src/main/javascript/MainTopic.js @@ -192,12 +192,13 @@ mindplot.MainTopic.prototype._updatePositionOnChangeSize = function(oldSize, new } }; -mindplot.MainTopic.prototype.setPosition = function(point) +mindplot.MainTopic.prototype.setPosition = function(point, fireEvent) { mindplot.MainTopic.superClass.setPosition.call(this, point); // Update board zero entry position... - mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMoveEvent,[this]); + if(fireEvent != false) + mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMoveEvent,[this]); }; mindplot.MainTopic.prototype.workoutIncomingConnectionPoint = function(sourcePosition) diff --git a/mindplot/src/main/javascript/MainTopicBoard.js b/mindplot/src/main/javascript/MainTopicBoard.js index 9a8d69b3..6d256e64 100644 --- a/mindplot/src/main/javascript/MainTopicBoard.js +++ b/mindplot/src/main/javascript/MainTopicBoard.js @@ -24,7 +24,7 @@ mindplot.MainTopicBoard = function(topic, layoutManager) this._height = 0; }; -objects.extend(mindplot.MainTopicBoard, mindplot.TopicBoard); +objects.extend(mindplot.MainTopicBoard, mindplot.Board); mindplot.MainTopicBoard.DEFAULT_MAIN_TOPIC_HEIGHT = 18; diff --git a/mindplot/src/main/javascript/MindmapDesigner.js b/mindplot/src/main/javascript/MindmapDesigner.js index 480e2ad9..a20b1f5e 100644 --- a/mindplot/src/main/javascript/MindmapDesigner.js +++ b/mindplot/src/main/javascript/MindmapDesigner.js @@ -456,7 +456,7 @@ mindplot.MindmapDesigner.prototype._nodeModelToNodeGraph = function(nodeModel, i var children = nodeModel.getChildren().slice(); // Sort children by order to solve adding order in for OriginalLayoutManager... - if (this._layoutManager.getType() == mindplot.layoutManagers.OriginalLayoutManager.NAME && nodeGraph.getTopicType()!=mindplot.NodeModel.CENTRAL_TOPIC_TYPE && children.length > 0) + if (this._layoutManager.getClassName() == mindplot.layoutManagers.OriginalLayoutManager.NAME && nodeGraph.getTopicType()!=mindplot.NodeModel.CENTRAL_TOPIC_TYPE && children.length > 0) { var oldChildren = children; children = []; diff --git a/mindplot/src/main/javascript/ScreenManager.js b/mindplot/src/main/javascript/ScreenManager.js index ddb84b3a..c44e26c7 100644 --- a/mindplot/src/main/javascript/ScreenManager.js +++ b/mindplot/src/main/javascript/ScreenManager.js @@ -29,11 +29,11 @@ mindplot.ScreenManager.prototype.setScale = function(scale) }; mindplot.ScreenManager.prototype.addEventListener=function(event, listener){ - $(this._divContainer).addListener(event, listener); + $(this._divContainer).addEvent(event, listener); }; mindplot.ScreenManager.prototype.removeEventListener=function(event, listener){ - $(this._divContainer).removeListener(event, listener); + $(this._divContainer).removeEvent(event, listener); }; mindplot.ScreenManager.prototype.getWorkspaceElementPosition = function(e) diff --git a/mindplot/src/main/javascript/TopicBoard.js b/mindplot/src/main/javascript/TopicBoard.js index 37379e65..676d05fd 100644 --- a/mindplot/src/main/javascript/TopicBoard.js +++ b/mindplot/src/main/javascript/TopicBoard.js @@ -16,12 +16,12 @@ * limitations under the License. */ -mindplot.TopicBoard = function() +mindplot.Board = function() { this._height = null; }; -mindplot.TopicBoard.prototype._removeEntryByOrder = function(order, position) +mindplot.Board.prototype._removeEntryByOrder = function(order, position) { var board = this._getBoard(position); var entry = board.lookupEntryByOrder(order); @@ -31,7 +31,7 @@ mindplot.TopicBoard.prototype._removeEntryByOrder = function(order, position) board.update(entry); }; -mindplot.TopicBoard.prototype.removeTopicFromBoard = function(topic) +mindplot.Board.prototype.removeTopicFromBoard = function(topic) { var position = topic.getPosition(); var order = topic.getOrder(); @@ -40,12 +40,12 @@ mindplot.TopicBoard.prototype.removeTopicFromBoard = function(topic) topic.setOrder(null); }; -mindplot.TopicBoard.prototype.positionateDragTopic = function(dragTopic) +mindplot.Board.prototype.positionateDragTopic = function(dragTopic) { throw "this method must be overrided"; }; -mindplot.TopicBoard.prototype.getHeight = function() +mindplot.Board.prototype.getHeight = function() { var board = this._getBoard(); return board.getHeight(); diff --git a/mindplot/src/main/javascript/commands/DragTopicCommand.js b/mindplot/src/main/javascript/commands/DragTopicCommand.js index 8b066ee8..35430baf 100644 --- a/mindplot/src/main/javascript/commands/DragTopicCommand.js +++ b/mindplot/src/main/javascript/commands/DragTopicCommand.js @@ -36,14 +36,14 @@ mindplot.commands.DragTopicCommand = mindplot.Command.extend( var origParentTopic = topic.getOutgoingConnectedTopic(); var origOrder = null; var origPosition = null; - if (topic.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE && origParentTopic != null && origParentTopic.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE) - { +// if (topic.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE && origParentTopic != null && origParentTopic.getType() == mindplot.NodeModel.MAIN_TOPIC_TYPE) +// { // In this case, topics are positioned using order ... origOrder = topic.getOrder(); - } else - { +// } else +// { origPosition = topic.getPosition().clone(); - } +// } // Disconnect topic .. if (origParentTopic) diff --git a/mindplot/src/main/javascript/layoutManagers/BaseLayoutManager.js b/mindplot/src/main/javascript/layoutManagers/BaseLayoutManager.js index 1036252a..0d7e69a6 100644 --- a/mindplot/src/main/javascript/layoutManagers/BaseLayoutManager.js +++ b/mindplot/src/main/javascript/layoutManagers/BaseLayoutManager.js @@ -1,24 +1,3 @@ -/* -Class: BaseLayoutManager - Base class for LayoutManagers - -Arguments: - element - the knob container - knob - the handle - options - see Options below - -Options: - steps - the number of steps for your slider. - mode - either 'horizontal' or 'vertical'. defaults to horizontal. - offset - relative offset for knob position. default to 0. - -Events: - onChange - a function to fire when the value changes. - onComplete - a function to fire when you're done dragging. - onTick - optionally, you can alter the onTick behavior, for example displaying an effect of the knob moving to the desired position. - Passes as parameter the new position. -*/ - mindplot.layoutManagers.BaseLayoutManager = new Class({ options: { @@ -27,15 +6,60 @@ mindplot.layoutManagers.BaseLayoutManager = new Class({ initialize: function(designer, options) { this.setOptions(options); + this._boards = new Hash(); this._designer = designer; + mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent,this._nodeResizeEvent.bind(this)); + mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent,this._nodeMoveEvent.bind(this)); + mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeDisconnectEvent,this._nodeDisconnectEvent.bind(this)); + mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeConnectEvent,this._nodeConnectEvent.bind(this)); + mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeRepositionateEvent,this._NodeRepositionateEvent.bind(this)); }, - addNode: function(node) { - + _nodeResizeEvent:function(node){ + }, + _nodeMoveEvent:function(node){ + //todo: Usar un solo board para todos los nodos. Testear que ande el set margin cuando se mueven los nodos. + this.getTopicBoardForTopic(node).updateChildrenPosition(node); + }, + _nodeDisconnectEvent:function(targetNode, node){ + this.getTopicBoardForTopic(targetNode).removeTopicFromBoard(node); + }, + _nodeConnectEvent:function(targetNode, node){ + this.getTopicBoardForTopic(targetNode).addBranch(node); + }, + _NodeRepositionateEvent:function(node){ + }, + getTopicBoardForTopic:function(node){ + var id = node.getId() + var result = this._boards[id]; + if(!result){ + result = this.addNode(node); + } + return result; + }, + addNode:function(node){ + var board = null; + if (this._isCentralTopic(node)) + board = this._createCentralTopicBoard(node); + else + board = this._createMainTopicBoard(node); + var id = node.getId(); + this._boards[id]=board; + return board; + }, + _createMainTopicBoard:function(node){ + return new mindplot.layoutManagers.boards.Board(node, this); + }, + _createCentralTopicBoard:function(node){ + return new mindplot.layoutManagers.boards.Board(node, this); }, getDesigner:function(){ return this._designer; }, - getType:function(){ + _isCentralTopic:function(node){ + var type = node.getModel().getType(); + return type == mindplot.NodeModel.CENTRAL_TOPIC_TYPE; + }, + getClassName:function(){ return mindplot.layoutManagers.BaseLayoutManager.NAME; } }); diff --git a/mindplot/src/main/javascript/layoutManagers/FreeMindLayoutManager.js b/mindplot/src/main/javascript/layoutManagers/FreeMindLayoutManager.js new file mode 100644 index 00000000..17b53dad --- /dev/null +++ b/mindplot/src/main/javascript/layoutManagers/FreeMindLayoutManager.js @@ -0,0 +1,128 @@ +mindplot.layoutManagers.FreeMindLayoutManager = mindplot.layoutManagers.BaseLayoutManager.extend({ + options:{ + + }, + initialize:function(designer, options){ + this.parent(designer, options); + }, + registerListenersOnNode : function(topic) + { + var id = topic.getId(); + console.log("registering on node: "+id); + // Register node listeners ... + var designer = this.getDesigner(); + topic.addEventListener('onfocus', function(event) + { + designer.onObjectFocusEvent.attempt([topic, event], designer); + }); + + // Add drag behaviour ... + if (topic.getType() != mindplot.NodeModel.CENTRAL_TOPIC_TYPE) + { + topic.addEventListener("mousedown",this._mousedownListener.bindWithEvent(this,[topic])); + } + + /*// Register editor events ... + if (!this._viewMode) + { + this._editor.listenEventOnNode(topic, 'dblclick', true); + }*/ + + }, + _mousedownListener:function(event,topic){ + + var workSpace = this._designer.getWorkSpace(); + if (workSpace.isWorkspaceEventsEnabled()) + { + // Disable double drag... + workSpace.enableWorkspaceEvents(false); + + var id = topic.getId(); + console.log("down on node: "+id); + var topics = this.getDesigner()._getTopics(); + // Disable all mouse events. + for (var i = 0; i < topics.length; i++) + { + topics[i].setMouseEventsEnabled(false); + } + + var ev = new Event(event); + + var screen = workSpace.getScreenManager(); + + // Set initial position. + // var mousePos = screen.getWorkspaceMousePosition(event); + + // Register mouse move listener ... + this._mouseMoveListenerInstance = this._mouseMoveListener.bindWithEvent(this,[topic]); + screen.addEventListener('mousemove', this._mouseMoveListenerInstance); + + // Register mouse up listeners ... + this._mouseUpListenerInstance = this._mouseUpListener.bindWithEvent(this,[topic]); + screen.addEventListener('mouseup', this._mouseUpListenerInstance); + + // Change cursor. + window.document.body.style.cursor = 'move'; + } + }, + _mouseMoveListener:function(event, node){ + var screen = this._designer.getWorkSpace().getScreenManager(); + var nodePos = node.getPosition(); + var pos = screen.getWorkspaceMousePosition(event); + var x = nodePos.x - pos.x; + var y = nodePos.y - pos.y; + var delta = new core.Point(x, y); + var board = this.getTopicBoardForTopic(node.getParent()); + board.setNodeMarginTop(node, delta); + //update children position + this._updateNodePos(node, delta); + event.preventDefault(); + }, + _mouseUpListener:function(event, node){ + var id = node.getId(); + console.log("up on node: "+id); + + var screen = this._designer.getWorkSpace().getScreenManager(); + // Remove all the events. + screen.removeEventListener('mousemove', this._mouseMoveListenerInstance); + screen.removeEventListener('mouseup', this._mouseUpListenerInstance); + delete this._mouseMoveListenerInstance; + delete this._mouseUpListenerInstance; + + var topics = this.getDesigner()._getTopics(); + // Disable all mouse events. + for (var i = 0; i < topics.length; i++) + { + topics[i].setMouseEventsEnabled(true); + } + + // Change the cursor to the default. + window.document.body.style.cursor = 'default'; + + this._designer.getWorkSpace().enableWorkspaceEvents(true); + +// var topicId = draggedTopic.getId(); +// var command = new mindplot.commands.DragTopicCommand(topicId); + + }, + _updateNodePos:function(node, delta){ + var pos = node.getPosition(); + node.setPosition(new core.Point(pos.x-delta.x, pos.y-delta.y)); + /*var children = node._getChildren(); + for (var i = 0; i < children.length; i++) + { + this._updateNodePos(children[i],delta); + }*/ + }, + getClassName:function(){ + return mindplot.layoutManagers.FreeMindLayoutManager.NAME; + }, + _createMainTopicBoard:function(node){ + return new mindplot.layoutManagers.boards.freeMindBoards.MainTopicBoard(node, this); + }, + _createCentralTopicBoard:function(node){ + return new mindplot.layoutManagers.boards.freeMindBoards.CentralTopicBoard(node, this); + } +}); + +mindplot.layoutManagers.FreeMindLayoutManager.NAME ="FreeMindLayoutManager"; \ No newline at end of file diff --git a/mindplot/src/main/javascript/layoutManagers/LayoutManagerFactory.js b/mindplot/src/main/javascript/layoutManagers/LayoutManagerFactory.js index 3eb20f22..d1e9d3ed 100644 --- a/mindplot/src/main/javascript/layoutManagers/LayoutManagerFactory.js +++ b/mindplot/src/main/javascript/layoutManagers/LayoutManagerFactory.js @@ -1,7 +1,7 @@ mindplot.layoutManagers.LayoutManagerFactory = {}; mindplot.layoutManagers.LayoutManagerFactory.managers = { - OriginalLayoutManager:mindplot.layoutManagers.OriginalLayoutManager -// FreeLayoutManager:mindplot.layoutManagers.FreeLayoutManager + OriginalLayoutManager:mindplot.layoutManagers.OriginalLayoutManager, + FreeMindLayoutManager:mindplot.layoutManagers.FreeMindLayoutManager }; mindplot.layoutManagers.LayoutManagerFactory.getManagerByName = function(name){ var manager = mindplot.layoutManagers.LayoutManagerFactory.managers[name+"Manager"]; diff --git a/mindplot/src/main/javascript/layoutManagers/OriginalLayoutManager.js b/mindplot/src/main/javascript/layoutManagers/OriginalLayoutManager.js index 17e9864b..e810013a 100644 --- a/mindplot/src/main/javascript/layoutManagers/OriginalLayoutManager.js +++ b/mindplot/src/main/javascript/layoutManagers/OriginalLayoutManager.js @@ -4,7 +4,6 @@ mindplot.layoutManagers.OriginalLayoutManager = mindplot.layoutManagers.BaseLayo }, initialize:function(designer, options){ this.parent(designer, options); - this._boards = new Hash(); this._dragTopicPositioner = new mindplot.DragTopicPositioner(this); // Init dragger manager. var workSpace = this.getDesigner().getWorkSpace(); @@ -12,27 +11,12 @@ mindplot.layoutManagers.OriginalLayoutManager = mindplot.layoutManagers.BaseLayo // Add shapes to speed up the loading process ... mindplot.DragTopic.initialize(workSpace); - - mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent,this._nodeResizeEvent.bind(this)); - mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent,this._nodeMoveEvent.bind(this)); - mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeDisconnectEvent,this._nodeDisconnectEvent.bind(this)); - mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeConnectEvent,this._nodeConnectEvent.bind(this)); - mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeRepositionateEvent,this._NodeRepositionateEvent.bind(this)); }, _nodeResizeEvent:function(node){ var size = node.getSize(); if(!this._isCentralTopic(node)) this.getTopicBoardForTopic(node).updateChildrenPosition(node,size.height/2); }, - _nodeMoveEvent:function(node){ - this.getTopicBoardForTopic(node).updateChildrenPosition(node); - }, - _nodeDisconnectEvent:function(targetNode, node){ - this.getTopicBoardForTopic(targetNode).removeTopicFromBoard(node); - }, - _nodeConnectEvent:function(targetNode, node){ - this.getTopicBoardForTopic(targetNode).addBranch(node); - }, _NodeRepositionateEvent:function(node){ this.getTopicBoardForTopic(node).repositionate(); }, @@ -117,29 +101,13 @@ mindplot.layoutManagers.OriginalLayoutManager = mindplot.layoutManagers.BaseLayo }*/ }, - getTopicBoardForTopic:function(node){ - var id = node.getId() - var result = this._boards[id]; - if(!result){ - result = this.addNode(node); - } - return result; + _createMainTopicBoard:function(node){ + return new mindplot.MainTopicBoard(node, this); }, - addNode:function(node){ - var boardClass = mindplot.MainTopicBoard; - if (this._isCentralTopic(node)) - boardClass = mindplot.CentralTopicBoard; - var board = new boardClass(node, this); - var id = node.getId(); - this._boards[id]=board; - this.parent(); - return board; + _createCentralTopicBoard:function(node){ + return new mindplot.CentralTopicBoard(node,this); }, - _isCentralTopic:function(node){ - var type = node.getModel().getType(); - return type == mindplot.NodeModel.CENTRAL_TOPIC_TYPE; - }, - getType:function(){ + getClassName:function(){ return mindplot.layoutManagers.OriginalLayoutManager.NAME; } }); diff --git a/mindplot/src/main/javascript/layoutManagers/boards/Board.js b/mindplot/src/main/javascript/layoutManagers/boards/Board.js new file mode 100644 index 00000000..1701f8fc --- /dev/null +++ b/mindplot/src/main/javascript/layoutManagers/boards/Board.js @@ -0,0 +1,33 @@ +mindplot.layoutManagers.boards={}; + +mindplot.layoutManagers.boards.Board = new Class({ + + options: { + + }, + initialize: function(node, layoutManager, options) { + this.setOptions(options); + this._node = node; + this._layoutManager = layoutManager; + }, + getClassName:function(){ + return mindplot.layoutManagers.boards.Board.NAME; + }, + removeTopicFromBoard:function(node){ + core.Utils.assert(false, "no Board implementation found!"); + }, + addBranch:function(node){ + core.Utils.assert(false, "no Board implementation found!"); + }, + updateChildrenPosition:function(node){ + core.Utils.assert(false, "no Board implementation found!"); + }, + setNodeMarginTop:function(node, delta){ + core.Utils.assert(false, "no Board implementation found!"); + } +}); + +mindplot.layoutManagers.boards.Board.NAME ="Board"; + +mindplot.layoutManagers.boards.Board.implement(new Events); +mindplot.layoutManagers.boards.Board.implement(new Options); \ No newline at end of file diff --git a/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Board.js b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Board.js new file mode 100644 index 00000000..133a44a8 --- /dev/null +++ b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Board.js @@ -0,0 +1,118 @@ +mindplot.layoutManagers.boards.freeMindBoards={}; + +mindplot.layoutManagers.boards.freeMindBoards.Board = mindplot.layoutManagers.boards.Board.extend({ + options:{ + + }, + initialize:function(node, layoutManager, options){ + this.parent(node, layoutManager, options); + this._positionTables = this._createTables(); + }, + _createTables:function(){ + core.Utils.assert(false, "no Board implementation found!") + }, + _getTableForNode:function(node){ + core.Utils.assert(false, "no Board implementation found!") + }, + removeTopicFromBoard:function(node){ + var table = this._getTableForNode(node); + var position = node.getPosition(); + var y = position.y; + + //search for position + for(var i = 0; i< table.length ; i++){ + var entry = table[i]; + if (entry.position == y){ + this._removeEntry(node, table, i); + break; + } + } + }, + addBranch:function(node){ + var result = this.findNodeEntryIndex(node); + this._insertNewEntry(node, result.table, result.index); + }, + _insertNewEntry:function(node, table, index){ + var entry = new mindplot.layoutManagers.boards.freeMindBoards.Entry(node); + table.splice(index, 0, entry); + this._updateTable(index, table); + }, + _removeEntry:function(node, table, index){ + table.splice(index, 1); + this._updateTable(index, table); + }, + _updateTable:function(index, table){ + var i = index; + if(index >= table.length){ + i = table.length -1; + } + + var modifiedTopics = []; + var delta = null; + //check from index to 0; + if(i>0){ + var entry = table[i]; + var prevEntry = table[i-1]; + var marginTop = entry.getPosition() + entry.getMarginTop(); + var marginBottom = prevEntry.getPosition() - prevEntry.getMarginBottom(); + if(marginTop>marginBottom){ + delta = marginBottom - marginTop; + i--; + while(i >= 0){ + this._moveTopic(table[i], delta, modifiedTopics); + i--; + } + } + } + + i = index; + delta = null; + + //check from index to length + if( imarginBottom){ + delta = marginTop-marginBottom; + i++; + while(i= this._DEFAULT_GAP){ + this._marginTop = value; + } + }, + getMarginBottom:function(){ + return this._marginTop; + } +}); \ No newline at end of file diff --git a/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/MainTopicBoard.js b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/MainTopicBoard.js new file mode 100644 index 00000000..0b17f245 --- /dev/null +++ b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/MainTopicBoard.js @@ -0,0 +1,14 @@ +mindplot.layoutManagers.boards.freeMindBoards.MainTopicBoard = mindplot.layoutManagers.boards.freeMindBoards.Board.extend({ + options:{ + + }, + initialize:function(node, layoutManager, options){ + this.parent(node, layoutManager, options); + }, + _createTables:function(){ + return [[]]; + }, + _getTableForNode:function(node){ + return this._positionTables[0]; + } +}); \ No newline at end of file diff --git a/mindplot/src/test/javascript/simpleTest.js b/mindplot/src/test/javascript/simpleTest.js new file mode 100644 index 00000000..c0e6d12b --- /dev/null +++ b/mindplot/src/test/javascript/simpleTest.js @@ -0,0 +1,128 @@ +TestCase("Mindplot test",{ + setUp:function(){ + /*:DOC +=
*/ + var mapId = '1'; + var mapXml = ''; + var editorProperties = {"zoom":0.7}; + var isTryMode = false; + + afterMindpotLibraryLoading = function() + { + buildMindmapDesigner(); + + // Register Events ... + $(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer)); + + /*// Autosave ... + if (!isTryMode) + { + var autosave = function() { + + if (designer.needsSave()) + { + designer.save(function() + { + // var monitor = core.Monitor.getInstance(); + }, false); + } + }; + autosave.periodical(30000); + + // To prevent the user from leaving the page with changes ... + window.onbeforeunload = function confirmExit() + { + if (designer.needsSave()) + { + designer.save(null, false) + } + } + }*/ + + }; + + var buildMindmapDesigner = function() + { + + // Initialize message logger ... + var container = $('mindplot'); + + // Initialize Editor ... + + var screenWidth = window.getWidth(); + var screenHeight = window.getHeight(); + + // Positionate node ... + // header - footer + screenHeight = screenHeight - 90 - 61; + + // body margin ... + editorProperties.width = screenWidth; + editorProperties.height = screenHeight; + + designer = new mindplot.MindmapDesigner(editorProperties, container); + designer.loadFromXML(mapId, mapXml); + + + /*// Save map on load .... + if (editorProperties.saveOnLoad) + { + var saveOnLoad = function() { + designer.save(function() { + }, false); + }.delay(1000) + }*/ + + } + afterMindpotLibraryLoading(); + }, + testWorkspaceBuild:function(){ + assertNotNull($('workspace')); + }, + testCentralTopicPresent:function(){ + var centralTopic = designer.getCentralTopic(); + assertNotNull(centralTopic); + var position = centralTopic.getPosition(); + assertEquals(0,position.x); + assertEquals(0,position.y); + }, + testMouseCreateMainTopic:function(){ + var centralTopic = designer.getCentralTopic(); + assertNotNull(centralTopic); + var target = designer.getWorkSpace().getScreenManager().getContainer(); + var size = designer._getTopics().length; + fireNativeEvent('dblclick',target,new core.Point(50,50)); + assertEquals(size+1, designer._getTopics().length); + } + +}); + +var fireNativeEvent = function(type, target, position){ + var event; + if(core.UserAgent.isIE()){ + event = document.createEventObject(); + event.screenX = position.x; + event.screenY = position.y; + target.dispatchEvent(event); + }else{ + var eventFamily; + if(type == "click" || type == "mousedown" || type == "mousemove" || type == "mouseout" || type == "mouseover" || + type == "mouseup" || type == "dblclick") + eventFamily = "MouseEvents"; + else if(type == "keydown" || type == "keypress" || type == "keyup" || type=="DOMActivate" || type == "DOMFocusIn" || + type == "DOMFocusOut") + eventFamily = "UIEvents"; + else if(type == "abort" || type == "blur" || type == "change" || type == "error" || type == "focus" || type == "load" + || type == "reset" || type == "resize" || type == "scroll" || type == "select" || type == "submit" || type == "unload") + eventFamily = "HTMLEvents"; + else if(type == "DOMAttrModified" || type == "DOMNodeInserted" || type == "DOMNodeRemoved" + || type == "DOMCharacterDataModified" || type == "DOMNodeInsertedIntoDocument" || type == "DOMNodeRemovedFromDocument" + || type == "DOMSubtreeModified") + eventFamily = "MutationEvents"; + else + eventFamily = "Events"; + event = document.createEvent(eventFamily); + event.initEvent(type,true,false, target, 0, position.x, position.y); + target.fireEvent(type, event); + } + return event; +}; diff --git a/mindplot/src/test/jsTestDriver.conf b/mindplot/src/test/jsTestDriver.conf new file mode 100644 index 00000000..5497d998 --- /dev/null +++ b/mindplot/src/test/jsTestDriver.conf @@ -0,0 +1,7 @@ +server: http://localhost:9876 + +load: + - ../../../wise-webapp/src/main/webapp/js/mootools.js + - ../../../core-js/target/classes/core.js + - ../../target/classes/mindplot.svg.js + - javascript/*.js \ No newline at end of file