mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-11 01:33:24 +01:00
removing .bind mootools call (phase 1/2)
This commit is contained in:
parent
3655df6cb8
commit
f2b0eb74ea
@ -29,30 +29,26 @@ mindplot.ControlPoint = new Class({
|
|||||||
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
|
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
|
||||||
|
|
||||||
this._isBinded = false;
|
this._isBinded = false;
|
||||||
|
var me = this;
|
||||||
this._controlPointsController[0].addEvent('mousedown', function(event) {
|
this._controlPointsController[0].addEvent('mousedown', function(event) {
|
||||||
(this._mouseDown.bind(this))(event, mindplot.ControlPoint.FROM);
|
(me._mouseDown)(event, mindplot.ControlPoint.FROM, me);
|
||||||
}.bind(this));
|
});
|
||||||
this._controlPointsController[0].addEvent('click', function(event) {
|
this._controlPointsController[0].addEvent('click', function(event) {
|
||||||
(this._mouseClick.bind(this))(event);
|
(me._mouseClick)(event);
|
||||||
}.bind(this));
|
});
|
||||||
this._controlPointsController[0].addEvent('dblclick', function(event) {
|
this._controlPointsController[0].addEvent('dblclick', function(event) {
|
||||||
(this._mouseClick.bind(this))(event);
|
(me._mouseClick)(event);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
this._controlPointsController[1].addEvent('mousedown', function(event) {
|
this._controlPointsController[1].addEvent('mousedown', function(event) {
|
||||||
(this._mouseDown.bind(this))(event, mindplot.ControlPoint.TO);
|
(me._mouseDown)(event, mindplot.ControlPoint.TO, me);
|
||||||
}.bind(this));
|
});
|
||||||
this._controlPointsController[1].addEvent('click', function(event) {
|
this._controlPointsController[1].addEvent('click', function(event) {
|
||||||
(this._mouseClick.bind(this))(event);
|
(me._mouseClick)(event);
|
||||||
}.bind(this));
|
});
|
||||||
this._controlPointsController[1].addEvent('dblclick', function(event) {
|
this._controlPointsController[1].addEvent('dblclick', function(event) {
|
||||||
(this._mouseClick.bind(this))(event);
|
(me._mouseClick)(event);
|
||||||
}.bind(this));
|
});
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
setSide : function(side) {
|
|
||||||
this._side = side;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setLine : function(line) {
|
setLine : function(line) {
|
||||||
@ -91,18 +87,17 @@ mindplot.ControlPoint = new Class({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_mouseDown : function(event, point) {
|
_mouseDown : function(event, point, me) {
|
||||||
if (!this._isBinded) {
|
if (!this._isBinded) {
|
||||||
this._isBinded = true;
|
this._isBinded = true;
|
||||||
|
|
||||||
this._mouseMoveFunction = function(event) {
|
this._mouseMoveFunction = function(event) {
|
||||||
(this._mouseMoveEvent.bind(this))(event, point);
|
(me._mouseMoveEvent)(event, point, me);
|
||||||
}.bind(this);
|
};
|
||||||
|
|
||||||
this._workspace.getScreenManager().addEvent('mousemove', this._mouseMoveFunction);
|
this._workspace.getScreenManager().addEvent('mousemove', this._mouseMoveFunction);
|
||||||
this._mouseUpFunction = function(event) {
|
this._mouseUpFunction = function(event) {
|
||||||
(this._mouseUp.bind(this))(event, point);
|
(me._mouseUp)(event, point, me);
|
||||||
}.bind(this);
|
};
|
||||||
this._workspace.getScreenManager().addEvent('mouseup', this._mouseUpFunction);
|
this._workspace.getScreenManager().addEvent('mouseup', this._mouseUpFunction);
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -35,9 +35,10 @@ mindplot.Designer = new Class({
|
|||||||
var commandContext = new mindplot.CommandContext(this);
|
var commandContext = new mindplot.CommandContext(this);
|
||||||
this._actionDispatcher = new mindplot.StandaloneActionDispatcher(commandContext);
|
this._actionDispatcher = new mindplot.StandaloneActionDispatcher(commandContext);
|
||||||
|
|
||||||
|
var me = this;
|
||||||
this._actionDispatcher.addEvent("modelUpdate", function (event) {
|
this._actionDispatcher.addEvent("modelUpdate", function (event) {
|
||||||
this.fireEvent("modelUpdate", event);
|
me.fireEvent("modelUpdate", event);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
||||||
this._model = new mindplot.DesignerModel(options);
|
this._model = new mindplot.DesignerModel(options);
|
||||||
@ -130,37 +131,34 @@ mindplot.Designer = new Class({
|
|||||||
_registerMouseEvents:function () {
|
_registerMouseEvents:function () {
|
||||||
var workspace = this._workspace;
|
var workspace = this._workspace;
|
||||||
var screenManager = workspace.getScreenManager();
|
var screenManager = workspace.getScreenManager();
|
||||||
|
var me = this;
|
||||||
// Initialize workspace event listeners.
|
// Initialize workspace event listeners.
|
||||||
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 = me.getModel().getTopics();
|
||||||
_.each(topics, function(object){
|
_.each(topics, function(object){
|
||||||
object.closeEditors();
|
object.closeEditors();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clean some selected nodes on event ..
|
// Clean some selected nodes on event ..
|
||||||
if (this._cleanScreen)
|
if (me._cleanScreen)
|
||||||
this._cleanScreen();
|
me._cleanScreen();
|
||||||
|
});
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
// Deselect on click ...
|
// Deselect on click ...
|
||||||
screenManager.addEvent('click', function (event) {
|
screenManager.addEvent('click', function (event) {
|
||||||
this.onObjectFocusEvent(null, event);
|
me.onObjectFocusEvent(null, event);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
// Create nodes on double click...
|
// Create nodes on double click...
|
||||||
screenManager.addEvent('dblclick', function (event) {
|
screenManager.addEvent('dblclick', function (event) {
|
||||||
if (workspace.isWorkspaceEventsEnabled()) {
|
if (workspace.isWorkspaceEventsEnabled()) {
|
||||||
|
|
||||||
var mousePos = screenManager.getWorkspaceMousePosition(event);
|
var mousePos = screenManager.getWorkspaceMousePosition(event);
|
||||||
|
var centralTopic = me.getModel().getCentralTopic();
|
||||||
var centralTopic = this.getModel().getCentralTopic();
|
var model = me._createChildModel(centralTopic, mousePos);
|
||||||
var model = this._createChildModel(centralTopic, mousePos);
|
|
||||||
this._actionDispatcher.addTopics([model], [centralTopic.getId()]);
|
this._actionDispatcher.addTopics([model], [centralTopic.getId()]);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
// Register mouse drag and drop event ...
|
// Register mouse drag and drop event ...
|
||||||
function noopHandler(evt) {
|
function noopHandler(evt) {
|
||||||
@ -254,13 +252,13 @@ mindplot.Designer = new Class({
|
|||||||
// Create node graph ...
|
// Create node graph ...
|
||||||
var topic = mindplot.NodeGraph.create(model, {readOnly:readOnly});
|
var topic = mindplot.NodeGraph.create(model, {readOnly:readOnly});
|
||||||
this.getModel().addTopic(topic);
|
this.getModel().addTopic(topic);
|
||||||
|
var me = this;
|
||||||
// Add Topic events ...
|
// Add Topic events ...
|
||||||
if (!readOnly) {
|
if (!readOnly) {
|
||||||
// If a node had gained focus, clean the rest of the nodes ...
|
// If a node had gained focus, clean the rest of the nodes ...
|
||||||
topic.addEvent('mousedown', function (event) {
|
topic.addEvent('mousedown', function (event) {
|
||||||
this.onObjectFocusEvent(topic, event);
|
me.onObjectFocusEvent(topic, event);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
// Register node listeners ...
|
// Register node listeners ...
|
||||||
if (topic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (topic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
@ -292,24 +290,24 @@ mindplot.Designer = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
topic.addEvent('ontblur', function () {
|
topic.addEvent('ontblur', function () {
|
||||||
var topics = this.getModel().filterSelectedTopics();
|
var topics = me.getModel().filterSelectedTopics();
|
||||||
var rels = this.getModel().filterSelectedRelationships();
|
var rels = me.getModel().filterSelectedRelationships();
|
||||||
|
|
||||||
if (topics.length == 0 || rels.length == 0) {
|
if (topics.length == 0 || rels.length == 0) {
|
||||||
this.fireEvent('onblur');
|
me.fireEvent('onblur');
|
||||||
}
|
}
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
topic.addEvent('ontfocus', function () {
|
topic.addEvent('ontfocus', function () {
|
||||||
var topics = this.getModel().filterSelectedTopics();
|
var topics = me.getModel().filterSelectedTopics();
|
||||||
var rels = this.getModel().filterSelectedRelationships();
|
var rels = me.getModel().filterSelectedRelationships();
|
||||||
|
|
||||||
if (topics.length == 1 || rels.length == 1) {
|
if (topics.length == 1 || rels.length == 1) {
|
||||||
this.fireEvent('onfocus');
|
me.fireEvent('onfocus');
|
||||||
}
|
}
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
return topic;
|
return topic;
|
||||||
},
|
},
|
||||||
|
|
||||||
onObjectFocusEvent:function (currentObject, event) {
|
onObjectFocusEvent:function (currentObject, event) {
|
||||||
@ -630,12 +628,13 @@ mindplot.Designer = new Class({
|
|||||||
// Init layout manager ...
|
// Init layout manager ...
|
||||||
var size = {width:25, height:25};
|
var size = {width:25, height:25};
|
||||||
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
|
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
|
||||||
|
var me = this;
|
||||||
layoutManager.addEvent('change', function (event) {
|
layoutManager.addEvent('change', function (event) {
|
||||||
var id = event.getId();
|
var id = event.getId();
|
||||||
var topic = this.getModel().findTopicById(id);
|
var topic = me.getModel().findTopicById(id);
|
||||||
topic.setPosition(event.getPosition());
|
topic.setPosition(event.getPosition());
|
||||||
topic.setOrder(event.getOrder());
|
topic.setOrder(event.getOrder());
|
||||||
}.bind(this));
|
});
|
||||||
this._eventBussDispatcher.setLayoutManager(layoutManager);
|
this._eventBussDispatcher.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
|
||||||
@ -753,24 +752,25 @@ mindplot.Designer = new Class({
|
|||||||
|
|
||||||
// Build relationship line ....
|
// Build relationship line ....
|
||||||
var result = new mindplot.Relationship(sourceTopic, targetTopic, model);
|
var result = new mindplot.Relationship(sourceTopic, targetTopic, model);
|
||||||
|
var me = this;
|
||||||
|
|
||||||
result.addEvent('ontblur', function () {
|
result.addEvent('ontblur', function () {
|
||||||
var topics = this.getModel().filterSelectedTopics();
|
var topics = me.getModel().filterSelectedTopics();
|
||||||
var rels = this.getModel().filterSelectedRelationships();
|
var rels = me.getModel().filterSelectedRelationships();
|
||||||
|
|
||||||
if (topics.length == 0 || rels.length == 0) {
|
if (topics.length == 0 || rels.length == 0) {
|
||||||
this.fireEvent('onblur');
|
me.fireEvent('onblur');
|
||||||
}
|
}
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
result.addEvent('ontfocus', function () {
|
result.addEvent('ontfocus', function () {
|
||||||
var topics = this.getModel().filterSelectedTopics();
|
var topics = me.getModel().filterSelectedTopics();
|
||||||
var rels = this.getModel().filterSelectedRelationships();
|
var rels = me.getModel().filterSelectedRelationships();
|
||||||
|
|
||||||
if (topics.length == 1 || rels.length == 1) {
|
if (topics.length == 1 || rels.length == 1) {
|
||||||
this.fireEvent('onfocus');
|
me.fireEvent('onfocus');
|
||||||
}
|
}
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
// Append it to the workspace ...
|
// Append it to the workspace ...
|
||||||
dmodel.addRelationship(result);
|
dmodel.addRelationship(result);
|
||||||
|
@ -84,15 +84,16 @@ mindplot.DragConnector = new Class({
|
|||||||
// - Horizontal proximity
|
// - Horizontal proximity
|
||||||
// - It's already connected.
|
// - It's already connected.
|
||||||
var currentConnection = dragTopic.getConnectedToTopic();
|
var currentConnection = dragTopic.getConnectedToTopic();
|
||||||
|
var me = this;
|
||||||
topics = topics.sort(function (a, b) {
|
topics = topics.sort(function (a, b) {
|
||||||
var aPos = a.getPosition();
|
var aPos = a.getPosition();
|
||||||
var bPos = b.getPosition();
|
var bPos = b.getPosition();
|
||||||
|
|
||||||
var av = this._isVerticallyAligned(a.getSize(), aPos, sPos);
|
var av = me._isVerticallyAligned(a.getSize(), aPos, sPos);
|
||||||
var bv = this._isVerticallyAligned(b.getSize(), bPos, sPos);
|
var bv = me._isVerticallyAligned(b.getSize(), bPos, sPos);
|
||||||
return this._proximityWeight(av, a, sPos, currentConnection) - this._proximityWeight(bv, b, sPos, currentConnection);
|
return me._proximityWeight(av, a, sPos, currentConnection) - me._proximityWeight(bv, b, sPos, currentConnection);
|
||||||
|
|
||||||
}.bind(this));
|
});
|
||||||
return topics;
|
return topics;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -31,14 +31,14 @@ mindplot.DragManager = new Class({
|
|||||||
var workspace = this._workspace;
|
var workspace = this._workspace;
|
||||||
var screen = workspace.getScreenManager();
|
var screen = workspace.getScreenManager();
|
||||||
var dragManager = this;
|
var dragManager = this;
|
||||||
|
var me = this;
|
||||||
var mouseDownListener = function(event) {
|
var mouseDownListener = function(event) {
|
||||||
if (workspace.isWorkspaceEventsEnabled()) {
|
if (workspace.isWorkspaceEventsEnabled()) {
|
||||||
// Disable double drag...
|
// Disable double drag...
|
||||||
workspace.enableWorkspaceEvents(false);
|
workspace.enableWorkspaceEvents(false);
|
||||||
|
|
||||||
// Set initial position.
|
// Set initial position.
|
||||||
var layoutManager = this._eventDispatcher.getLayoutManager();
|
var layoutManager = me._eventDispatcher.getLayoutManager();
|
||||||
var dragNode = node.createDragNode(layoutManager);
|
var dragNode = node.createDragNode(layoutManager);
|
||||||
|
|
||||||
// Register mouse move listener ...
|
// Register mouse move listener ...
|
||||||
@ -52,7 +52,7 @@ mindplot.DragManager = new Class({
|
|||||||
// Change cursor.
|
// Change cursor.
|
||||||
window.document.body.style.cursor = 'move';
|
window.document.body.style.cursor = 'move';
|
||||||
}
|
}
|
||||||
}.bind(this);
|
};
|
||||||
node.addEvent('mousedown', mouseDownListener);
|
node.addEvent('mousedown', mouseDownListener);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -70,10 +70,10 @@ mindplot.DragManager = new Class({
|
|||||||
|
|
||||||
_buildMouseMoveListener : function(workspace, dragNode, dragManager) {
|
_buildMouseMoveListener : function(workspace, dragNode, dragManager) {
|
||||||
var screen = workspace.getScreenManager();
|
var screen = workspace.getScreenManager();
|
||||||
|
var me = this;
|
||||||
var result = function(event) {
|
var result = function(event) {
|
||||||
|
|
||||||
if (!this._isDragInProcess) {
|
if (!me._isDragInProcess) {
|
||||||
// Execute Listeners ..
|
// Execute Listeners ..
|
||||||
var startDragListener = dragManager._listeners['startdragging'];
|
var startDragListener = dragManager._listeners['startdragging'];
|
||||||
startDragListener(event, dragNode);
|
startDragListener(event, dragNode);
|
||||||
@ -81,7 +81,7 @@ mindplot.DragManager = new Class({
|
|||||||
// Add shadow node to the workspace.
|
// Add shadow node to the workspace.
|
||||||
workspace.append(dragNode);
|
workspace.append(dragNode);
|
||||||
|
|
||||||
this._isDragInProcess = true;
|
me._isDragInProcess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pos = screen.getWorkspaceMousePosition(event);
|
var pos = screen.getWorkspaceMousePosition(event);
|
||||||
@ -95,13 +95,14 @@ mindplot.DragManager = new Class({
|
|||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
}.bind(this);
|
};
|
||||||
dragManager._mouseMoveListener = result;
|
dragManager._mouseMoveListener = result;
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildMouseUpListener : function(workspace, node, dragNode, dragManager) {
|
_buildMouseUpListener : function(workspace, node, dragNode, dragManager) {
|
||||||
var screen = workspace.getScreenManager();
|
var screen = workspace.getScreenManager();
|
||||||
|
var me = this;
|
||||||
var result = function(event) {
|
var result = function(event) {
|
||||||
$assert(dragNode.isDragTopic, 'dragNode must be an DragTopic');
|
$assert(dragNode.isDragTopic, 'dragNode must be an DragTopic');
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ mindplot.DragManager = new Class({
|
|||||||
// Change the cursor to the default.
|
// Change the cursor to the default.
|
||||||
window.document.body.style.cursor = 'default';
|
window.document.body.style.cursor = 'default';
|
||||||
|
|
||||||
if (this._isDragInProcess) {
|
if (me._isDragInProcess) {
|
||||||
|
|
||||||
// Execute Listeners only if the node has been moved.
|
// Execute Listeners only if the node has been moved.
|
||||||
var endDragListener = dragManager._listeners['enddragging'];
|
var endDragListener = dragManager._listeners['enddragging'];
|
||||||
@ -126,11 +127,11 @@ mindplot.DragManager = new Class({
|
|||||||
// Remove drag node from the workspace.
|
// Remove drag node from the workspace.
|
||||||
dragNode.removeFromWorkspace(workspace);
|
dragNode.removeFromWorkspace(workspace);
|
||||||
|
|
||||||
this._isDragInProcess = false;
|
me._isDragInProcess = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}.bind(this);
|
};
|
||||||
dragManager._mouseUpListener = result;
|
dragManager._mouseUpListener = result;
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
@ -101,11 +101,11 @@ mindplot.IconGroup = new Class({
|
|||||||
|
|
||||||
this._icons.erase(icon);
|
this._icons.erase(icon);
|
||||||
this._resize(this._icons.length);
|
this._resize(this._icons.length);
|
||||||
|
var me = this;
|
||||||
// Add all again ...
|
// Add all again ...
|
||||||
_.each(this._icons, function (elem, i) {
|
_.each(this._icons, function (elem, i) {
|
||||||
this._positionIcon(elem, i);
|
me._positionIcon(elem, i);
|
||||||
}.bind(this));
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
moveToFront:function () {
|
moveToFront:function () {
|
||||||
|
@ -29,19 +29,20 @@ mindplot.commands.AddTopicCommand = new Class({
|
|||||||
|
|
||||||
execute:function (commandContext) {
|
execute:function (commandContext) {
|
||||||
|
|
||||||
|
var me = this;
|
||||||
_.each(this._models, function (model, index) {
|
_.each(this._models, function (model, index) {
|
||||||
|
|
||||||
// Add a new topic ...
|
// Add a new topic ...
|
||||||
var topic = commandContext.createTopic(model);
|
var topic = commandContext.createTopic(model);
|
||||||
|
|
||||||
// Connect to topic ...
|
// Connect to topic ...
|
||||||
if (this._parentsIds) {
|
if (me._parentsIds) {
|
||||||
var parentId = this._parentsIds[index];
|
var parentId = me._parentsIds[index];
|
||||||
if ($defined(parentId)) {
|
if ($defined(parentId)) {
|
||||||
var parentTopic = commandContext.findTopics(parentId)[0];
|
var parentTopic = commandContext.findTopics(parentId)[0];
|
||||||
commandContext.connect(topic, parentTopic);
|
commandContext.connect(topic, parentTopic);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
commandContext.addTopic(topic);
|
commandContext.addTopic(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ mindplot.commands.AddTopicCommand = new Class({
|
|||||||
// Render node ...
|
// Render node ...
|
||||||
topic.setVisibility(true);
|
topic.setVisibility(true);
|
||||||
|
|
||||||
}.bind(this));
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
undoExecute:function (commandContext) {
|
undoExecute:function (commandContext) {
|
||||||
@ -69,7 +70,7 @@ mindplot.commands.AddTopicCommand = new Class({
|
|||||||
var topicId = model.getId();
|
var topicId = model.getId();
|
||||||
var topic = commandContext.findTopics(topicId)[0];
|
var topic = commandContext.findTopics(topicId)[0];
|
||||||
commandContext.deleteTopic(topic);
|
commandContext.deleteTopic(topic);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
this._models = clonedModel;
|
this._models = clonedModel;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ mindplot.commands.DeleteCommand = new Class({
|
|||||||
// Add rebuild relationships ...
|
// Add rebuild relationships ...
|
||||||
_.each(this._deletedRelModel, function (model) {
|
_.each(this._deletedRelModel, function (model) {
|
||||||
commandContext.addRelationship(model);
|
commandContext.addRelationship(model);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
// Finally display the topics ...
|
// Finally display the topics ...
|
||||||
_.each(this._deletedTopicModels, function (topicModel) {
|
_.each(this._deletedTopicModels, function (topicModel) {
|
||||||
|
@ -46,10 +46,11 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (topics != null) {
|
if (topics != null) {
|
||||||
|
var me = this;
|
||||||
_.each(topics, function (topic) {
|
_.each(topics, function (topic) {
|
||||||
var oldValue = this._commandFunc(topic, this._value);
|
var oldValue = me._commandFunc(topic, me._value);
|
||||||
this._oldValues.push(oldValue);
|
me._oldValues.push(oldValue);
|
||||||
}.bind(this));
|
});
|
||||||
}
|
}
|
||||||
this.applied = true;
|
this.applied = true;
|
||||||
|
|
||||||
@ -62,10 +63,11 @@ mindplot.commands.GenericFunctionCommand = new Class({
|
|||||||
undoExecute:function (commandContext) {
|
undoExecute:function (commandContext) {
|
||||||
if (this.applied) {
|
if (this.applied) {
|
||||||
var topics = commandContext.findTopics(this._topicsId);
|
var topics = commandContext.findTopics(this._topicsId);
|
||||||
|
var me = this;
|
||||||
_.each(topics, function (topic, index) {
|
_.each(topics, function (topic, index) {
|
||||||
this._commandFunc(topic, this._oldValues[index]);
|
me._commandFunc(topic, me._oldValues[index]);
|
||||||
|
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
this.applied = false;
|
this.applied = false;
|
||||||
this._oldValues = [];
|
this._oldValues = [];
|
||||||
|
@ -26,9 +26,13 @@ mindplot.layout.GridSorter = new Class({
|
|||||||
var children = this._getSortedChildren(treeSet, node);
|
var children = this._getSortedChildren(treeSet, node);
|
||||||
|
|
||||||
// Compute heights ...
|
// Compute heights ...
|
||||||
|
var me = this;
|
||||||
var heights = children.map(function(child) {
|
var heights = children.map(function(child) {
|
||||||
return {id:child.getId(),height:this._computeChildrenHeight(treeSet, child)};
|
return {
|
||||||
}.bind(this));
|
id: child.getId(),
|
||||||
|
height: me._computeChildrenHeight(treeSet, child)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// Calculate the offsets ...
|
// Calculate the offsets ...
|
||||||
var result = {};
|
var result = {};
|
||||||
|
@ -107,12 +107,12 @@ mindplot.layout.OriginalLayout = new Class({
|
|||||||
var sorter = node.getSorter();
|
var sorter = node.getSorter();
|
||||||
var offsetById = sorter.computeOffsets(this._treeSet, node);
|
var offsetById = sorter.computeOffsets(this._treeSet, node);
|
||||||
var parentPosition = node.getPosition();
|
var parentPosition = node.getPosition();
|
||||||
|
var me = this;
|
||||||
_.each(children, function (child) {
|
_.each(children, function (child) {
|
||||||
var offset = offsetById[child.getId()];
|
var offset = offsetById[child.getId()];
|
||||||
|
|
||||||
var childFreeDisplacement = child.getFreeDisplacement();
|
var childFreeDisplacement = child.getFreeDisplacement();
|
||||||
var direction = node.getSorter().getChildDirection(this._treeSet, child);
|
var direction = node.getSorter().getChildDirection(me._treeSet, child);
|
||||||
|
|
||||||
if ((direction > 0 && childFreeDisplacement.x < 0) || (direction < 0 && childFreeDisplacement.x > 0)) {
|
if ((direction > 0 && childFreeDisplacement.x < 0) || (direction < 0 && childFreeDisplacement.x > 0)) {
|
||||||
child.resetFreeDisplacement();
|
child.resetFreeDisplacement();
|
||||||
@ -125,9 +125,9 @@ mindplot.layout.OriginalLayout = new Class({
|
|||||||
var parentX = parentPosition.x;
|
var parentX = parentPosition.x;
|
||||||
var parentY = parentPosition.y;
|
var parentY = parentPosition.y;
|
||||||
|
|
||||||
var newPos = {x:parentX + offset.x, y:parentY + offset.y + this._calculateAlignOffset(node, child, heightById)};
|
var newPos = {x:parentX + offset.x, y:parentY + offset.y + me._calculateAlignOffset(node, child, heightById)};
|
||||||
this._treeSet.updateBranchPosition(child, newPos);
|
me._treeSet.updateBranchPosition(child, newPos);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
node._branchHeight = newBranchHeight;
|
node._branchHeight = newBranchHeight;
|
||||||
}
|
}
|
||||||
|
@ -240,9 +240,10 @@ 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);
|
||||||
|
var me = this;
|
||||||
_.each(children, function (child) {
|
_.each(children, function (child) {
|
||||||
this.shiftBranchPosition(child, xOffset, yOffset);
|
me.shiftBranchPosition(child, xOffset, yOffset);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -251,9 +252,10 @@ 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);
|
||||||
|
var me = this;
|
||||||
_.each(children, function (child) {
|
_.each(children, function (child) {
|
||||||
this.shiftBranchPosition(child, xOffset, yOffset);
|
me.shiftBranchPosition(child, xOffset, yOffset);
|
||||||
}.bind(this));
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getSiblingsInVerticalDirection:function (node, yOffset) {
|
getSiblingsInVerticalDirection:function (node, yOffset) {
|
||||||
|
@ -286,7 +286,7 @@ mindplot.model.INodeModel = new Class({
|
|||||||
result = result + key + ":" + value + ",";
|
result = result + key + ":" + value + ",";
|
||||||
});
|
});
|
||||||
result = result + "}"
|
result = result + "}"
|
||||||
}.bind(this));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
result = result + ' }';
|
result = result + ' }';
|
||||||
|
@ -32,9 +32,10 @@ mindplot.persistence.Beta2PelaMigrator = new Class({
|
|||||||
|
|
||||||
// Beta does not set position on second level nodes ...
|
// Beta does not set position on second level nodes ...
|
||||||
var branches = mindmap.getBranches();
|
var branches = mindmap.getBranches();
|
||||||
|
var me = this;
|
||||||
_.each(branches, function (model) {
|
_.each(branches, function (model) {
|
||||||
this._fixPosition(model);
|
me._fixPosition(model);
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
return mindmap;
|
return mindmap;
|
||||||
},
|
},
|
||||||
@ -42,11 +43,12 @@ mindplot.persistence.Beta2PelaMigrator = new Class({
|
|||||||
_fixPosition:function (parentModel) {
|
_fixPosition:function (parentModel) {
|
||||||
var parentPos = parentModel.getPosition();
|
var parentPos = parentModel.getPosition();
|
||||||
var isRight = parentPos.x > 0;
|
var isRight = parentPos.x > 0;
|
||||||
|
var me = this;
|
||||||
_.each(parentModel.getChildren(), function (child) {
|
_.each(parentModel.getChildren(), function (child) {
|
||||||
if (!child.getPosition()) {
|
if (!child.getPosition()) {
|
||||||
child.setPosition(parentPos.x + (50 * isRight ? 1 : -1), parentPos.y);
|
child.setPosition(parentPos.x + (50 * isRight ? 1 : -1), parentPos.y);
|
||||||
}
|
}
|
||||||
this._fixPosition(child);
|
me._fixPosition(child);
|
||||||
}.bind(this));
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -27,11 +27,11 @@ mindplot.widget.IMenu = new Class({
|
|||||||
this._containerId = containerId;
|
this._containerId = containerId;
|
||||||
this._mapId = mapId;
|
this._mapId = mapId;
|
||||||
this._mindmapUpdated = false;
|
this._mindmapUpdated = false;
|
||||||
|
var me = this;
|
||||||
// Register update events ...
|
// Register update events ...
|
||||||
this._designer.addEvent('modelUpdate', function () {
|
this._designer.addEvent('modelUpdate', function () {
|
||||||
this.setRequireChange(true);
|
me.setRequireChange(true);
|
||||||
}.bind(this));
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
clear:function () {
|
clear:function () {
|
||||||
|
@ -55,9 +55,9 @@ mindplot.widget.IconPanel = new Class({
|
|||||||
var panel = this;
|
var panel = this;
|
||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
img.on('click', function (event) {
|
img.on('click', function (event) {
|
||||||
model.setValue(this.attr('id'));
|
model.setValue($(this).attr('id'));
|
||||||
panel.hide();
|
panel.hide();
|
||||||
}.bind(img));
|
});
|
||||||
|
|
||||||
count = count + 1;
|
count = count + 1;
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,11 @@ mindplot.widget.ToolbarPaneItem = new Class({
|
|||||||
$assert(buttonId, "buttonId can not be null");
|
$assert(buttonId, "buttonId can not be null");
|
||||||
$assert(model, "model can not be null");
|
$assert(model, "model can not be null");
|
||||||
this._model = model;
|
this._model = model;
|
||||||
|
var me = this;
|
||||||
var fn = function() {
|
var fn = function() {
|
||||||
// Is the panel being displayed ?
|
// Is the panel being displayed ?
|
||||||
if (this.isVisible()) {
|
me.isVisible() ? me.hide() : me.show();
|
||||||
this.hide();
|
};
|
||||||
} else {
|
|
||||||
this.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}.bind(this);
|
|
||||||
this.parent(buttonId, fn, {topicAction:true,relAction:false});
|
this.parent(buttonId, fn, {topicAction:true,relAction:false});
|
||||||
this._panelElem = this._init();
|
this._panelElem = this._init();
|
||||||
this._visible = false;
|
this._visible = false;
|
||||||
|
@ -48,14 +48,16 @@ web2d.peer.svg.TextPeer = new Class({
|
|||||||
this._text = text;
|
this._text = text;
|
||||||
if (text) {
|
if (text) {
|
||||||
var lines = text.split('\n');
|
var lines = text.split('\n');
|
||||||
|
var me = this;
|
||||||
|
//FIXME: we could use underscorejs here
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
var tspan = window.document.createElementNS(this.svgNamespace, 'tspan');
|
var tspan = window.document.createElementNS(me.svgNamespace, 'tspan');
|
||||||
tspan.setAttribute('dy', '1em');
|
tspan.setAttribute('dy', '1em');
|
||||||
tspan.setAttribute('x', this.getPosition().x);
|
tspan.setAttribute('x', me.getPosition().x);
|
||||||
|
|
||||||
tspan.textContent = line.length == 0 ? " " : line;
|
tspan.textContent = line.length == 0 ? " " : line;
|
||||||
this._native.appendChild(tspan);
|
me._native.appendChild(tspan);
|
||||||
}.bind(this));
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user