mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
- Move keyboard events as part of a separate class.
- TextEditor is now one instance peer node. - Broken: f2 and start writting on typing.
This commit is contained in:
parent
78f312ef0a
commit
f3e024735d
@ -62,6 +62,7 @@
|
|||||||
<filelist dir="${basedir}/src/main/javascript/" files="ScreenManager.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="ScreenManager.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="Workspace.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="Workspace.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="ShrinkConnector.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="ShrinkConnector.js"/>
|
||||||
|
<filelist dir="${basedir}/src/main/javascript/" files="DesignerKeyboard.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="NodeGraph.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="NodeGraph.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="Topic.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="Topic.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="CentralTopic.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="CentralTopic.js"/>
|
||||||
@ -80,6 +81,7 @@
|
|||||||
<filelist dir="${basedir}/src/main/javascript/" files="TextEditorFactory.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="TextEditorFactory.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="VariableDistanceBoard.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="VariableDistanceBoard.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="util/Shape.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="util/Shape.js"/>
|
||||||
|
<filelist dir="${basedir}/src/main/javascript/" files="util/Converter.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="FixedDistanceBoard.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="FixedDistanceBoard.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="BoardEntry.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="BoardEntry.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/>
|
||||||
|
@ -21,15 +21,12 @@ mindplot.CentralTopic = new Class({
|
|||||||
Extends:mindplot.Topic,
|
Extends:mindplot.Topic,
|
||||||
initialize: function(model) {
|
initialize: function(model) {
|
||||||
this.parent(model);
|
this.parent(model);
|
||||||
this.registerEvents();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
registerEvents : function() {
|
_registerEvents : function() {
|
||||||
// Prevent click on the topics being propagated ...
|
this.parent();
|
||||||
this.addEventListener('click', function(event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// This disable the drag of the central topic. But solves the problem of deselecting the nodes when the screen is clicked.
|
||||||
this.addEventListener('mousedown', function(event) {
|
this.addEventListener('mousedown', function(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
|
266
mindplot/src/main/javascript/DesignerKeyboard.js
Normal file
266
mindplot/src/main/javascript/DesignerKeyboard.js
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
/*
|
||||||
|
* 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.DesignerKeyboard = new Class({
|
||||||
|
Extends:Keyboard,
|
||||||
|
initialize : function(designer) {
|
||||||
|
$assert(designer, "designer can not be null");
|
||||||
|
this.parent({defaultEventType: 'keydown'});
|
||||||
|
this._registerEvents(designer);
|
||||||
|
},
|
||||||
|
|
||||||
|
_registerEvents : function(designer) {
|
||||||
|
// Try with the keyboard ..
|
||||||
|
this.addEvents({
|
||||||
|
'esc' : function(event) {
|
||||||
|
var nodes = this.getSelectedNodes();
|
||||||
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
|
node = nodes[i];
|
||||||
|
node.setOnFocus(false);
|
||||||
|
}
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
}.bind(designer),
|
||||||
|
|
||||||
|
'backspace':function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'space' : function() {
|
||||||
|
var nodes = this.getSelectedNodes();
|
||||||
|
if (nodes.length > 0) {
|
||||||
|
var topic = nodes[0];
|
||||||
|
|
||||||
|
var model = topic.getModel();
|
||||||
|
var isShrink = !model.areChildrenShrinked();
|
||||||
|
topic.setChildrenShrinked(isShrink);
|
||||||
|
}
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'f2' : function() {
|
||||||
|
// @todo:
|
||||||
|
console.log("f2 Must be implented");
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'delete' : function() {
|
||||||
|
designer.deleteCurrentNode();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'enter' :
|
||||||
|
function() {
|
||||||
|
designer.createSiblingForSelectedNode();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'insert' : function() {
|
||||||
|
designer.createChildForSelectedNode();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'ctrl+z' : function() {
|
||||||
|
designer.undo();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'meta+z' : function() {
|
||||||
|
designer.undo();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'ctrl+z+shift' :function() {
|
||||||
|
designer.redo();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'meta+z+shift' : function() {
|
||||||
|
designer.redo();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'ctrl+a' : function(event) {
|
||||||
|
designer.selectAll();
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
'meta+a' : function(event) {
|
||||||
|
designer.selectAll();
|
||||||
|
event.preventDefault();
|
||||||
|
},
|
||||||
|
|
||||||
|
'right' : function() {
|
||||||
|
var nodes = designer.getSelectedNodes();
|
||||||
|
if (nodes.length > 0) {
|
||||||
|
var node = nodes[0];
|
||||||
|
if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
|
this._goToSideChild(designer, node, 'RIGHT');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (node.getPosition().x < 0) {
|
||||||
|
this._goToParent(designer, node);
|
||||||
|
}
|
||||||
|
else if (!node.areChildrenShrinked()) {
|
||||||
|
this._goToChild(designer, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var centralTopic = designer.getCentralTopic();
|
||||||
|
this._goToNode(designer, centralTopic);
|
||||||
|
}
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'left' : function() {
|
||||||
|
var nodes = designer.getSelectedNodes();
|
||||||
|
if (nodes.length > 0) {
|
||||||
|
var node = nodes[0];
|
||||||
|
if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
|
this._goToSideChild(designer, node, 'LEFT');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (node.getPosition().x > 0) {
|
||||||
|
this._goToParent(designer, node);
|
||||||
|
}
|
||||||
|
else if (!node.areChildrenShrinked()) {
|
||||||
|
this._goToChild(designer, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var centralTopic = designer.getCentralTopic();
|
||||||
|
this._goToNode(designer, centralTopic);
|
||||||
|
}
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'up' : function() {
|
||||||
|
// @ToDo: Ups, accessing a private method ...
|
||||||
|
var nodes = designer.getSelectedNodes();
|
||||||
|
if (nodes.length > 0) {
|
||||||
|
var node = nodes[0];
|
||||||
|
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
|
this._goToBrother(designer, node, 'UP');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var centralTopic = designer.getCentralTopic();
|
||||||
|
this._goToNode(designer, centralTopic);
|
||||||
|
}
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'down' : function() {
|
||||||
|
var nodes = designer.getSelectedNodes();
|
||||||
|
if (nodes.length > 0) {
|
||||||
|
var node = nodes[0];
|
||||||
|
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
|
this._goToBrother(designer, node, 'DOWN');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var centralTopic = designer.getCentralTopic();
|
||||||
|
this._goToNode(designer, centralTopic);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_goToBrother : function(designer, node, direction) {
|
||||||
|
var brothers = node._parent._getChildren();
|
||||||
|
var target = node;
|
||||||
|
var y = node.getPosition().y;
|
||||||
|
var x = node.getPosition().x;
|
||||||
|
var dist = null;
|
||||||
|
for (var i = 0; i < brothers.length; i++) {
|
||||||
|
var sameSide = (x * brothers[i].getPosition().x) >= 0;
|
||||||
|
if (brothers[i] != node && sameSide) {
|
||||||
|
var brother = brothers[i];
|
||||||
|
var brotherY = brother.getPosition().y;
|
||||||
|
if (direction == "DOWN" && brotherY > y) {
|
||||||
|
var distancia = y - brotherY;
|
||||||
|
if (distancia < 0) {
|
||||||
|
distancia = distancia * (-1);
|
||||||
|
}
|
||||||
|
if (dist == null || dist > distancia) {
|
||||||
|
dist = distancia;
|
||||||
|
target = brothers[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (direction == "UP" && brotherY < y) {
|
||||||
|
var distance = y - brotherY;
|
||||||
|
if (distance < 0) {
|
||||||
|
distance = distance * (-1);
|
||||||
|
}
|
||||||
|
if (dist == null || dist > distance) {
|
||||||
|
dist = distance;
|
||||||
|
target = brothers[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._goToNode(designer, target);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
_goToSideChild : function(designer, node, side) {
|
||||||
|
var children = node._getChildren();
|
||||||
|
if (children.length > 0) {
|
||||||
|
var target = children[0];
|
||||||
|
var top = null;
|
||||||
|
for (var i = 0; i < children.length; i++) {
|
||||||
|
var child = children[i];
|
||||||
|
var childY = child.getPosition().y;
|
||||||
|
if (side == 'LEFT' && child.getPosition().x < 0) {
|
||||||
|
if (top == null || childY < top) {
|
||||||
|
target = child;
|
||||||
|
top = childY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (side == 'RIGHT' && child.getPosition().x > 0) {
|
||||||
|
if (top == null || childY < top) {
|
||||||
|
target = child;
|
||||||
|
top = childY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this._goToNode(designer, target);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_goToParent : function(designer, node) {
|
||||||
|
var parent = node._parent;
|
||||||
|
this._goToNode(designer,parent);
|
||||||
|
},
|
||||||
|
|
||||||
|
_goToChild : function(designer, node) {
|
||||||
|
var children = node._getChildren();
|
||||||
|
if (children.length > 0) {
|
||||||
|
var target = children[0];
|
||||||
|
var top = target.getPosition().y;
|
||||||
|
for (var i = 0; i < children.length; i++) {
|
||||||
|
var child = children[i];
|
||||||
|
if (child.getPosition().y < top) {
|
||||||
|
top = child.getPosition().y;
|
||||||
|
target = child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._goToNode(designer,target);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_goToNode : function(designer, node) {
|
||||||
|
// First deselect all the nodes ...
|
||||||
|
designer.deselectAll();
|
||||||
|
|
||||||
|
// Give focus to the selected node....
|
||||||
|
node.setOnFocus(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
@ -42,7 +42,7 @@ mindplot.ImageIcon = new Class({
|
|||||||
removeImage.src = "../images/bin.png";
|
removeImage.src = "../images/bin.png";
|
||||||
removeImage.inject(container);
|
removeImage.inject(container);
|
||||||
|
|
||||||
if (!$defined(designer._viewMode) || ($defined(designer._viewMode) && !designer._viewMode)) {
|
if (!$defined(designer._readOnly) || ($defined(designer._readOnly) && !designer._readOnly)) {
|
||||||
|
|
||||||
removeImage.addEvent('click', function() {
|
removeImage.addEvent('click', function() {
|
||||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||||
|
@ -81,7 +81,7 @@ mindplot.LinkIcon = new Class({
|
|||||||
attribution.inject(element);
|
attribution.inject(element);
|
||||||
element.inject(container);
|
element.inject(container);
|
||||||
|
|
||||||
if (!$defined(designer._viewMode) || ($defined(designer._viewMode) && !designer._viewMode)) {
|
if (!$defined(designer._readOnly) || ($defined(designer._readOnly) && !designer._readOnly)) {
|
||||||
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
|
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
|
||||||
var editBtn = new Element('input', {type:'button', 'class':'btn-primary', value:'Edit'}).addClass('button').inject(buttonContainer);
|
var editBtn = new Element('input', {type:'button', 'class':'btn-primary', value:'Edit'}).addClass('button').inject(buttonContainer);
|
||||||
var removeBtn = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}).addClass('button').inject(buttonContainer);
|
var removeBtn = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}).addClass('button').inject(buttonContainer);
|
||||||
|
@ -35,24 +35,79 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
// Initial Zoom
|
// Initial Zoom
|
||||||
this._zoom = profile.zoom;
|
this._zoom = profile.zoom;
|
||||||
this._viewMode = profile.viewMode;
|
|
||||||
|
|
||||||
// Init Screen manager..
|
// Init Screen manager..
|
||||||
var screenManager = new mindplot.ScreenManager(profile.width, profile.height, divElement);
|
var screenManager = new mindplot.ScreenManager(profile.width, profile.height, divElement);
|
||||||
this._workspace = new mindplot.Workspace(profile, screenManager, this._zoom);
|
this._workspace = new mindplot.Workspace(profile, screenManager, this._zoom);
|
||||||
|
this._readOnly = profile.readOnly;
|
||||||
//create editor
|
|
||||||
var editorClass = mindplot.TextEditorFactory.getTextEditorFromName(mindplot.EditorOptions.textEditor);
|
|
||||||
this._editor = new editorClass(this, this._actionRunner);
|
|
||||||
|
|
||||||
// Init layout managers ...
|
// Init layout managers ...
|
||||||
this._topics = [];
|
this._topics = [];
|
||||||
this._layoutManager = new mindplot.layout.OriginalLayoutManager(this);
|
this._layoutManager = new mindplot.layout.OriginalLayoutManager(this);
|
||||||
|
|
||||||
// Register handlers..
|
// Register handlers..
|
||||||
this._registerEvents();
|
|
||||||
this._relationships = {};
|
this._relationships = {};
|
||||||
this._events = {};
|
this._events = {};
|
||||||
|
|
||||||
|
// Register events
|
||||||
|
if (!profile.readOnly) {
|
||||||
|
this._registerEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
_registerEvents : function() {
|
||||||
|
// Register mouse events ...
|
||||||
|
this._registerMouseEvents();
|
||||||
|
|
||||||
|
// Register keyboard events ...
|
||||||
|
var keyboard = new mindplot.DesignerKeyboard(this);
|
||||||
|
keyboard.activate();
|
||||||
|
|
||||||
|
// To prevent the user from leaving the page with changes ...
|
||||||
|
window.addEvent('beforeunload', function () {
|
||||||
|
if (this.needsSave()) {
|
||||||
|
this.save(null, false)
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
_registerMouseEvents : function() {
|
||||||
|
var workspace = this._workspace;
|
||||||
|
var screenManager = workspace.getScreenManager();
|
||||||
|
|
||||||
|
// Initialize workspace event listeners.
|
||||||
|
screenManager.addEvent('drag', function(event) {
|
||||||
|
// Clean some selected nodes on event ..
|
||||||
|
this._cleanScreen();
|
||||||
|
|
||||||
|
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
// Deselect on click ...
|
||||||
|
screenManager.addEvent('click', function(event) {
|
||||||
|
this.onObjectFocusEvent(null, event);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
// Create nodes on double click...
|
||||||
|
screenManager.addEvent('dblclick', function(event) {
|
||||||
|
if (workspace.isWorkspaceEventsEnabled()) {
|
||||||
|
// Get mouse position
|
||||||
|
var pos = screenManager.getWorkspaceMousePosition(event);
|
||||||
|
|
||||||
|
// Create a new topic model ...
|
||||||
|
var mindmap = this.getMindmap();
|
||||||
|
var model = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE);
|
||||||
|
model.setPosition(pos.x, pos.y);
|
||||||
|
|
||||||
|
// Get central topic ...
|
||||||
|
var centralTopic = this.getCentralTopic();
|
||||||
|
var centralTopicId = centralTopic.getId();
|
||||||
|
|
||||||
|
// Execute action ...
|
||||||
|
this._actionDispatcher.addTopic(model, centralTopicId, true);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_getTopics : function() {
|
_getTopics : function() {
|
||||||
@ -75,46 +130,6 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_registerEvents : function() {
|
|
||||||
var workspace = this._workspace;
|
|
||||||
var screenManager = workspace.getScreenManager();
|
|
||||||
|
|
||||||
if (!$defined(this._viewMode) || ($defined(this._viewMode) && !this._viewMode)) {
|
|
||||||
// Initialize workspace event listeners.
|
|
||||||
screenManager.addEvent('drag', function(event) {
|
|
||||||
// Clean some selected nodes on envet ..
|
|
||||||
this.getEditor().lostFocus();
|
|
||||||
this._cleanScreen();
|
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
// Deselect on click ...
|
|
||||||
// @Todo: Arreglar en el screen manager que si hay drag, no hay click...
|
|
||||||
screenManager.addEvent('click', function(event) {
|
|
||||||
this.onObjectFocusEvent(null, event);
|
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
// Create nodes on double click...
|
|
||||||
screenManager.addEvent('dblclick', function(event) {
|
|
||||||
if (workspace.isWorkspaceEventsEnabled()) {
|
|
||||||
this.getEditor().lostFocus();
|
|
||||||
// Get mouse position
|
|
||||||
var pos = screenManager.getWorkspaceMousePosition(event);
|
|
||||||
|
|
||||||
// Create a new topic model ...
|
|
||||||
var mindmap = this.getMindmap();
|
|
||||||
var model = mindmap.createNode(mindplot.model.NodeModel.MAIN_TOPIC_TYPE);
|
|
||||||
model.setPosition(pos.x, pos.y);
|
|
||||||
|
|
||||||
// Get central topic ...
|
|
||||||
var centralTopic = this.getCentralTopic();
|
|
||||||
var centralTopicId = centralTopic.getId();
|
|
||||||
|
|
||||||
// Execute action ...
|
|
||||||
this._actionDispatcher.addTopic(model, centralTopicId, true);
|
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_buildNodeGraph : function(model) {
|
_buildNodeGraph : function(model) {
|
||||||
var workspace = this._workspace;
|
var workspace = this._workspace;
|
||||||
@ -153,17 +168,17 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return topic;
|
return topic;
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
onObjectFocusEvent : function(currentObject, event) {
|
onObjectFocusEvent : function(currentObject, event) {
|
||||||
this.getEditor().lostFocus();
|
var objects = this.getObjects();
|
||||||
var selectableObjects = this.getSelectedObjects();
|
|
||||||
|
|
||||||
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
||||||
if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) {
|
if (!$defined(event) || (!event.ctrlKey && !event.metaKey)) {
|
||||||
selectableObjects.forEach(function(selectableObject) {
|
objects.forEach(function(object) {
|
||||||
if (selectableObject.isOnFocus() && selectableObject != currentObject) {
|
if (object.isOnFocus() && object != currentObject) {
|
||||||
selectableObject.setOnFocus(false);
|
object.setOnFocus(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -181,6 +196,20 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectAll : function() {
|
||||||
|
var objects = this.getObjects();
|
||||||
|
objects.forEach(function(object) {
|
||||||
|
object.setOnFocus(true);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
deselectAll : function() {
|
||||||
|
var objects = this.getObjects();
|
||||||
|
objects.forEach(function(object) {
|
||||||
|
object.setOnFocus(false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
zoomIn : function() {
|
zoomIn : function() {
|
||||||
var scale = this._zoom / 1.2;
|
var scale = this._zoom / 1.2;
|
||||||
if (scale >= 0.3) {
|
if (scale >= 0.3) {
|
||||||
@ -190,11 +219,12 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
else {
|
else {
|
||||||
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
createChildForSelectedNode : function() {
|
createChildForSelectedNode : function() {
|
||||||
|
|
||||||
var nodes = this._getSelectedNodes();
|
var nodes = this.getSelectedNodes();
|
||||||
if (nodes.length <= 0) {
|
if (nodes.length <= 0) {
|
||||||
// If there are more than one node selected,
|
// If there are more than one node selected,
|
||||||
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
||||||
@ -216,10 +246,11 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
// Execute event ...
|
// Execute event ...
|
||||||
this._actionDispatcher.addTopic(childModel, parentTopicId, true);
|
this._actionDispatcher.addTopic(childModel, parentTopicId, true);
|
||||||
|
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
createSiblingForSelectedNode : function() {
|
createSiblingForSelectedNode : function() {
|
||||||
var nodes = this._getSelectedNodes();
|
var nodes = this.getSelectedNodes();
|
||||||
if (nodes.length <= 0) {
|
if (nodes.length <= 0) {
|
||||||
// If there are more than one node selected,
|
// If there are more than one node selected,
|
||||||
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
core.Monitor.getInstance().logMessage('Could not create a topic. Only one node must be selected.');
|
||||||
@ -244,7 +275,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
this._actionDispatcher.addTopic(siblingModel, parentTopicId, true);
|
this._actionDispatcher.addTopic(siblingModel, parentTopicId, true);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
addRelationShip2SelectedNode : function(event) {
|
addRelationShip2SelectedNode : function(event) {
|
||||||
var screen = this._workspace.getScreenManager();
|
var screen = this._workspace.getScreenManager();
|
||||||
@ -267,7 +299,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
screen.addEvent('mousemove', this._relationshipMouseMoveFunction);
|
screen.addEvent('mousemove', this._relationshipMouseMoveFunction);
|
||||||
screen.addEvent('click', this._relationshipMouseClickFunction);
|
screen.addEvent('click', this._relationshipMouseClickFunction);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
_relationshipMouseMove : function(event) {
|
_relationshipMouseMove : function(event) {
|
||||||
var screen = this._workspace.getScreenManager();
|
var screen = this._workspace.getScreenManager();
|
||||||
@ -276,7 +309,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stop();
|
event.stop();
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
_relationshipMouseClick : function (event, fromNode) {
|
_relationshipMouseClick : function (event, fromNode) {
|
||||||
var target = event.target;
|
var target = event.target;
|
||||||
@ -296,7 +330,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stop();
|
event.stop();
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
addRelationship : function(fromNode, toNode) {
|
addRelationship : function(fromNode, toNode) {
|
||||||
// Create a new topic model ...
|
// Create a new topic model ...
|
||||||
@ -305,7 +340,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
this._actionDispatcher.addRelationship(model, mindmap);
|
this._actionDispatcher.addRelationship(model, mindmap);
|
||||||
|
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
needsSave : function() {
|
needsSave : function() {
|
||||||
return this._actionRunner.hasBeenChanged();
|
return this._actionRunner.hasBeenChanged();
|
||||||
@ -314,7 +350,6 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
autoSaveEnabled : function(value) {
|
autoSaveEnabled : function(value) {
|
||||||
if ($defined(value) && value) {
|
if ($defined(value) && value) {
|
||||||
var autosave = function() {
|
var autosave = function() {
|
||||||
|
|
||||||
if (this.needsSave()) {
|
if (this.needsSave()) {
|
||||||
this.save(null, false);
|
this.save(null, false);
|
||||||
}
|
}
|
||||||
@ -333,7 +368,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
// Refresh undo state...
|
// Refresh undo state...
|
||||||
this._actionRunner.markAsChangeBase();
|
this._actionRunner.markAsChangeBase();
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
loadFromCollaborativeModel: function(collaborationManager) {
|
loadFromCollaborativeModel: function(collaborationManager) {
|
||||||
var mindmap = collaborationManager.buildWiseModel();
|
var mindmap = collaborationManager.buildWiseModel();
|
||||||
@ -341,10 +377,11 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
// Place the focus on the Central Topic
|
// Place the focus on the Central Topic
|
||||||
var centralTopic = this.getCentralTopic();
|
var centralTopic = this.getCentralTopic();
|
||||||
this._goToNode.attempt(centralTopic, this);
|
this.goToNode.attempt(centralTopic, this);
|
||||||
|
|
||||||
this._fireEvent("loadsuccess");
|
this._fireEvent("loadsuccess");
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
loadFromXML : function(mapId, xmlContent) {
|
loadFromXML : function(mapId, xmlContent) {
|
||||||
$assert(xmlContent, 'mindmapId can not be null');
|
$assert(xmlContent, 'mindmapId can not be null');
|
||||||
@ -360,7 +397,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
// Place the focus on the Central Topic
|
// Place the focus on the Central Topic
|
||||||
var centralTopic = this.getCentralTopic();
|
var centralTopic = this.getCentralTopic();
|
||||||
this._goToNode.attempt(centralTopic, this);
|
this.goToNode.attempt(centralTopic, this);
|
||||||
|
|
||||||
this._fireEvent("loadsuccess");
|
this._fireEvent("loadsuccess");
|
||||||
|
|
||||||
@ -381,7 +418,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
|
|
||||||
// Place the focus on the Central Topic
|
// Place the focus on the Central Topic
|
||||||
var centralTopic = this.getCentralTopic();
|
var centralTopic = this.getCentralTopic();
|
||||||
this._goToNode.attempt(centralTopic, this);
|
this.goToNode.attempt(centralTopic, this);
|
||||||
|
|
||||||
this._fireEvent("loadsuccess");
|
this._fireEvent("loadsuccess");
|
||||||
}
|
}
|
||||||
@ -467,12 +504,14 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
workspace.appendChild(relationship);
|
workspace.appendChild(relationship);
|
||||||
relationship.redraw();
|
relationship.redraw();
|
||||||
return relationship;
|
return relationship;
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
createRelationship : function(model) {
|
createRelationship : function(model) {
|
||||||
this._mindmap.addRelationship(model);
|
this._mindmap.addRelationship(model);
|
||||||
return this._relationshipModelToRelationship(model);
|
return this._relationshipModelToRelationship(model);
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
removeRelationship : function(model) {
|
removeRelationship : function(model) {
|
||||||
this._mindmap.removeRelationship(model);
|
this._mindmap.removeRelationship(model);
|
||||||
@ -483,7 +522,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
targetTopic.removeRelationship(relationship);
|
targetTopic.removeRelationship(relationship);
|
||||||
this._workspace.removeChild(relationship);
|
this._workspace.removeChild(relationship);
|
||||||
delete this._relationships[model.getId()];
|
delete this._relationships[model.getId()];
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
_buildRelationship : function (model) {
|
_buildRelationship : function (model) {
|
||||||
var elem = this;
|
var elem = this;
|
||||||
@ -534,11 +574,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
this._relationships[model.getId()] = relationLine;
|
this._relationships[model.getId()] = relationLine;
|
||||||
|
|
||||||
return relationLine;
|
return relationLine;
|
||||||
},
|
}
|
||||||
|
,
|
||||||
getEditor : function() {
|
|
||||||
return this._editor;
|
|
||||||
},
|
|
||||||
|
|
||||||
_removeNode : function(node) {
|
_removeNode : function(node) {
|
||||||
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
@ -558,10 +595,11 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
model.deleteNode();
|
model.deleteNode();
|
||||||
|
|
||||||
if ($defined(parent)) {
|
if ($defined(parent)) {
|
||||||
this._goToNode(parent);
|
this.goToNode(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
deleteCurrentNode : function() {
|
deleteCurrentNode : function() {
|
||||||
|
|
||||||
@ -574,7 +612,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
this._actionDispatcher.deleteTopics(selectedObjects);
|
this._actionDispatcher.deleteTopics(selectedObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
setFont2SelectedNode : function(font) {
|
setFont2SelectedNode : function(font) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||||
@ -583,7 +622,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font);
|
this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
setStyle2SelectedNode : function() {
|
setStyle2SelectedNode : function() {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||||
@ -591,7 +631,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontStyleToTopic(topicsIds);
|
this._actionDispatcher.changeFontStyleToTopic(topicsIds);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
setFontColor2SelectedNode : function(color) {
|
setFontColor2SelectedNode : function(color) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||||
@ -599,7 +640,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontColorToTopic(topicsIds, color);
|
this._actionDispatcher.changeFontColorToTopic(topicsIds, color);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
setBackColor2SelectedNode : function(color) {
|
setBackColor2SelectedNode : function(color) {
|
||||||
|
|
||||||
@ -612,12 +654,13 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeBackgroundColorToTopic(topicsIds, color);
|
this._actionDispatcher.changeBackgroundColorToTopic(topicsIds, color);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
|
|
||||||
_getValidSelectedObjectsIds : function(validate, errorMsg) {
|
_getValidSelectedObjectsIds : function(validate, errorMsg) {
|
||||||
var result = {"nodes":[],"relationshipLines":[]};
|
var result = {"nodes":[],"relationshipLines":[]};
|
||||||
var selectedNodes = this._getSelectedNodes();
|
var selectedNodes = this.getSelectedNodes();
|
||||||
var selectedRelationshipLines = this.getSelectedRelationshipLines();
|
var selectedRelationshipLines = this.getSelectedRelationshipLines();
|
||||||
if (selectedNodes.length == 0 && selectedRelationshipLines.length == 0) {
|
if (selectedNodes.length == 0 && selectedRelationshipLines.length == 0) {
|
||||||
core.Monitor.getInstance().logMessage('At least one element must be selected to execute this operation.');
|
core.Monitor.getInstance().logMessage('At least one element must be selected to execute this operation.');
|
||||||
@ -651,7 +694,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
setBorderColor2SelectedNode : function(color) {
|
setBorderColor2SelectedNode : function(color) {
|
||||||
var validateFunc = function(topic) {
|
var validateFunc = function(topic) {
|
||||||
@ -664,7 +708,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeBorderColorToTopic(topicsIds, color);
|
this._actionDispatcher.changeBorderColorToTopic(topicsIds, color);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
setFontSize2SelectedNode : function(size) {
|
setFontSize2SelectedNode : function(size) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||||
@ -672,7 +717,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontSizeToTopic(topicsIds, size);
|
this._actionDispatcher.changeFontSizeToTopic(topicsIds, size);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
setShape2SelectedNode : function(shape) {
|
setShape2SelectedNode : function(shape) {
|
||||||
var validateFunc = function(topic) {
|
var validateFunc = function(topic) {
|
||||||
@ -685,7 +731,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeShapeToTopic(topicsIds, shape);
|
this._actionDispatcher.changeShapeToTopic(topicsIds, shape);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
|
|
||||||
setWeight2SelectedNode : function() {
|
setWeight2SelectedNode : function() {
|
||||||
@ -694,7 +741,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeFontWeightToTopic(topicsIds);
|
this._actionDispatcher.changeFontWeightToTopic(topicsIds);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
addIconType2SelectedNode : function(iconType) {
|
addIconType2SelectedNode : function(iconType) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||||
@ -702,7 +750,8 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.addIconToTopic(topicsIds[0], iconType);
|
this._actionDispatcher.addIconToTopic(topicsIds[0], iconType);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
,
|
||||||
|
|
||||||
addLink2Node : function(url) {
|
addLink2Node : function(url) {
|
||||||
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
var validSelectedObjects = this._getValidSelectedObjectsIds();
|
||||||
@ -807,7 +856,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_getSelectedNodes : function() {
|
getSelectedNodes : function() {
|
||||||
var result = new Array();
|
var result = new Array();
|
||||||
for (var i = 0; i < this._topics.length; i++) {
|
for (var i = 0; i < this._topics.length; i++) {
|
||||||
if (this._topics[i].isOnFocus()) {
|
if (this._topics[i].isOnFocus()) {
|
||||||
@ -828,259 +877,17 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
getSelectedNodes : function() {
|
getObjects : function() {
|
||||||
return this._getSelectedNodes();
|
var result = [].append(this._topics);
|
||||||
|
for (var id in this._relationships) {
|
||||||
|
result.push(this._relationships[id]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
getSelectedObjects : function() {
|
goToNode : function(node) {
|
||||||
var selectedNodes = this.getSelectedNodes();
|
|
||||||
var selectedRelationships = this.getSelectedRelationshipLines();
|
|
||||||
selectedRelationships.extend(selectedNodes);
|
|
||||||
return selectedRelationships;
|
|
||||||
},
|
|
||||||
|
|
||||||
keyEventHandler : function(event) {
|
|
||||||
if (this._workspace.isWorkspaceEventsEnabled()) {
|
|
||||||
var evt = (event) ? event : window.event;
|
|
||||||
|
|
||||||
if (evt.keyCode == 8) {
|
|
||||||
if ($defined(event)) {
|
|
||||||
if ($defined(event.preventDefault)) {
|
|
||||||
event.preventDefault();
|
|
||||||
} else {
|
|
||||||
event.returnValue = false;
|
|
||||||
}
|
|
||||||
new Event(event).stop();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
evt.returnValue = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// @ToDo: I think that some of the keys has been removed ... Check this...
|
|
||||||
evt = new Event(event);
|
|
||||||
var key = evt.key;
|
|
||||||
if (!this._editor.isVisible()) {
|
|
||||||
if (((evt.code >= 65 && evt.code <= 90) || (evt.code >= 48 && evt.code <= 57)) && !(evt.control || evt.meta)) {
|
|
||||||
if ($defined(evt.shift)) {
|
|
||||||
key = key.toUpperCase();
|
|
||||||
}
|
|
||||||
this._showEditor(key);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var nodes;
|
|
||||||
var node;
|
|
||||||
switch (key) {
|
|
||||||
case 'delete':
|
|
||||||
this.deleteCurrentNode();
|
|
||||||
break;
|
|
||||||
case 'enter':
|
|
||||||
if (!evt.meta) {
|
|
||||||
this.createSiblingForSelectedNode();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'insert':
|
|
||||||
this.createChildForSelectedNode();
|
|
||||||
break;
|
|
||||||
case 'right':
|
|
||||||
nodes = this._getSelectedNodes();
|
|
||||||
if (nodes.length > 0) {
|
|
||||||
node = nodes[0];
|
|
||||||
if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
|
||||||
this._goToSideChild(node, 'RIGHT');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (node.getPosition().x < 0) {
|
|
||||||
this._goToParent(node);
|
|
||||||
}
|
|
||||||
else if (!node.areChildrenShrinked()) {
|
|
||||||
this._goToChild(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this._goToNode(this._topics[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'left':
|
|
||||||
nodes = this._getSelectedNodes();
|
|
||||||
if (nodes.length > 0) {
|
|
||||||
node = nodes[0];
|
|
||||||
if (node.getTopicType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
|
||||||
this._goToSideChild(node, 'LEFT');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (node.getPosition().x > 0) {
|
|
||||||
this._goToParent(node);
|
|
||||||
}
|
|
||||||
else if (!node.areChildrenShrinked()) {
|
|
||||||
this._goToChild(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this._goToNode(this._topics[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case'up':
|
|
||||||
nodes = this._getSelectedNodes();
|
|
||||||
if (nodes.length > 0) {
|
|
||||||
node = nodes[0];
|
|
||||||
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
|
||||||
this._goToBrother(node, 'UP');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this._goToNode(this._topics[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'down':
|
|
||||||
nodes = this._getSelectedNodes();
|
|
||||||
if (nodes.length > 0) {
|
|
||||||
node = nodes[0];
|
|
||||||
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
|
||||||
this._goToBrother(node, 'DOWN');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this._goToNode(this._topics[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'f2':
|
|
||||||
this._showEditor();
|
|
||||||
break;
|
|
||||||
case 'space':
|
|
||||||
nodes = this._getSelectedNodes();
|
|
||||||
if (nodes.length > 0) {
|
|
||||||
var topic = nodes[0];
|
|
||||||
|
|
||||||
var model = topic.getModel();
|
|
||||||
var isShrink = !model.areChildrenShrinked();
|
|
||||||
topic.setChildrenShrinked(isShrink);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'backspace':
|
|
||||||
evt.preventDefault();
|
|
||||||
break;
|
|
||||||
case 'esc':
|
|
||||||
nodes = this._getSelectedNodes();
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
|
||||||
node = nodes[i];
|
|
||||||
node.setOnFocus(false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'z':
|
|
||||||
if (evt.control || evt.meta) {
|
|
||||||
if (evt.shift) {
|
|
||||||
this.redo();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.undo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
evt.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_showEditor : function(key) {
|
|
||||||
var nodes = this._getSelectedNodes();
|
|
||||||
if (nodes.length == 1) {
|
|
||||||
var node = nodes[0];
|
|
||||||
if (key && key != "") {
|
|
||||||
this._editor.setInitialText(key);
|
|
||||||
}
|
|
||||||
this._editor.getFocusEvent.attempt(node, this._editor);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_goToBrother : function(node, direction) {
|
|
||||||
var brothers = node._parent._getChildren();
|
|
||||||
var target = node;
|
|
||||||
var y = node.getPosition().y;
|
|
||||||
var x = node.getPosition().x;
|
|
||||||
var dist = null;
|
|
||||||
for (var i = 0; i < brothers.length; i++) {
|
|
||||||
var sameSide = (x * brothers[i].getPosition().x) >= 0;
|
|
||||||
if (brothers[i] != node && sameSide) {
|
|
||||||
var brother = brothers[i];
|
|
||||||
var brotherY = brother.getPosition().y;
|
|
||||||
if (direction == "DOWN" && brotherY > y) {
|
|
||||||
var distancia = y - brotherY;
|
|
||||||
if (distancia < 0) {
|
|
||||||
distancia = distancia * (-1);
|
|
||||||
}
|
|
||||||
if (dist == null || dist > distancia) {
|
|
||||||
dist = distancia;
|
|
||||||
target = brothers[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (direction == "UP" && brotherY < y) {
|
|
||||||
var distancia = y - brotherY;
|
|
||||||
if (distancia < 0) {
|
|
||||||
distancia = distancia * (-1);
|
|
||||||
}
|
|
||||||
if (dist == null || dist > distancia) {
|
|
||||||
dist = distancia;
|
|
||||||
target = brothers[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._goToNode(target);
|
|
||||||
},
|
|
||||||
|
|
||||||
_goToNode : function(node) {
|
|
||||||
node.setOnFocus(true);
|
node.setOnFocus(true);
|
||||||
this.onObjectFocusEvent.attempt(node, this);
|
this.onObjectFocusEvent(node);
|
||||||
},
|
|
||||||
|
|
||||||
_goToSideChild : function(node, side) {
|
|
||||||
var children = node._getChildren();
|
|
||||||
if (children.length > 0) {
|
|
||||||
var target = children[0];
|
|
||||||
var top = null;
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
|
||||||
var child = children[i];
|
|
||||||
var childY = child.getPosition().y;
|
|
||||||
if (side == 'LEFT' && child.getPosition().x < 0) {
|
|
||||||
if (top == null || childY < top) {
|
|
||||||
target = child;
|
|
||||||
top = childY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (side == 'RIGHT' && child.getPosition().x > 0) {
|
|
||||||
if (top == null || childY < top) {
|
|
||||||
target = child;
|
|
||||||
top = childY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._goToNode(target);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_goToParent : function(node) {
|
|
||||||
var parent = node._parent;
|
|
||||||
this._goToNode(parent);
|
|
||||||
},
|
|
||||||
|
|
||||||
_goToChild : function(node) {
|
|
||||||
var children = node._getChildren();
|
|
||||||
if (children.length > 0) {
|
|
||||||
var target = children[0];
|
|
||||||
var top = target.getPosition().y;
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
|
||||||
var child = children[i];
|
|
||||||
if (child.getPosition().y < top) {
|
|
||||||
top = child.getPosition().y;
|
|
||||||
target = child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._goToNode(target);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getWorkSpace : function() {
|
getWorkSpace : function() {
|
||||||
|
@ -22,6 +22,8 @@ mindplot.NodeGraph = new Class({
|
|||||||
this._mouseEvents = true;
|
this._mouseEvents = true;
|
||||||
this.setModel(nodeModel);
|
this.setModel(nodeModel);
|
||||||
this._onFocus = false;
|
this._onFocus = false;
|
||||||
|
this._textEditor = new mindplot.TextEditor(this);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getType : function() {
|
getType : function() {
|
||||||
@ -93,11 +95,13 @@ mindplot.NodeGraph = new Class({
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// @todo: node must not know about the topic.
|
// @todo: node must not know about the topic.
|
||||||
|
|
||||||
outerShape.setFill(mindplot.Topic.OUTER_SHAPE_ATTRIBUTES.fillColor);
|
outerShape.setFill(mindplot.Topic.OUTER_SHAPE_ATTRIBUTES.fillColor);
|
||||||
outerShape.setOpacity(0);
|
outerShape.setOpacity(0);
|
||||||
}
|
}
|
||||||
this.setCursor('move');
|
this.setCursor('move');
|
||||||
|
|
||||||
|
// In any case, always try to hide the editor ...
|
||||||
|
this._textEditor.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
isOnFocus : function() {
|
isOnFocus : function() {
|
||||||
|
@ -41,7 +41,7 @@ mindplot.Note = new Class({
|
|||||||
|
|
||||||
imgContainer.inject(container);
|
imgContainer.inject(container);
|
||||||
|
|
||||||
if (!$defined(designer._viewMode) || ($defined(designer._viewMode) && !designer._viewMode)) {
|
if (!$defined(designer._readOnly) || ($defined(designer._readOnly) && !designer._readOnly)) {
|
||||||
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
|
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
|
||||||
var editBtn = new Element('input', {type:'button', value:'Edit','class':'btn-primary'}).addClass('button').inject(buttonContainer);
|
var editBtn = new Element('input', {type:'button', value:'Edit','class':'btn-primary'}).addClass('button').inject(buttonContainer);
|
||||||
var removeBtn = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}).addClass('button').inject(buttonContainer);
|
var removeBtn = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}).addClass('button').inject(buttonContainer);
|
||||||
|
@ -20,7 +20,7 @@ mindplot.RichTextEditor = mindplot.TextEditor.extend({
|
|||||||
initialize:function(screenManager,actionRunner){
|
initialize:function(screenManager,actionRunner){
|
||||||
this.parent(screenManager, actionRunner);
|
this.parent(screenManager, actionRunner);
|
||||||
},
|
},
|
||||||
_createUI:function(){
|
_buildEditor:function(){
|
||||||
//Create editor ui
|
//Create editor ui
|
||||||
this._size = {width:440, height:200};
|
this._size = {width:440, height:200};
|
||||||
this._myOverlay = new Element('div').setStyles({position:"absolute", display: "none", zIndex: "8", top: "50%", left:"50%", marginLeft:"-200px", marginTop:"-90px", width:"400px", height:"180px"});
|
this._myOverlay = new Element('div').setStyles({position:"absolute", display: "none", zIndex: "8", top: "50%", left:"50%", marginLeft:"-200px", marginTop:"-90px", width:"400px", height:"180px"});
|
||||||
@ -33,7 +33,7 @@ mindplot.RichTextEditor = mindplot.TextEditor.extend({
|
|||||||
this._designer.getWorkSpace().appendChild(this._editorNode);
|
this._designer.getWorkSpace().appendChild(this._editorNode);
|
||||||
this._addListeners();
|
this._addListeners();
|
||||||
},
|
},
|
||||||
_addListeners:function(){
|
_registerListeners:function(){
|
||||||
|
|
||||||
$(this._myOverlay).addEvent('click', function(event){
|
$(this._myOverlay).addEvent('click', function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -91,7 +91,7 @@ mindplot.RichTextEditor = mindplot.TextEditor.extend({
|
|||||||
},
|
},
|
||||||
init:function(node){
|
init:function(node){
|
||||||
this._currentNode = node;
|
this._currentNode = node;
|
||||||
this.applyChanges = false;
|
this._applyChanges = false;
|
||||||
$(this._myOverlay.setStyle('display','block'));
|
$(this._myOverlay.setStyle('display','block'));
|
||||||
inst = this._editor.instanceById("inputText2");
|
inst = this._editor.instanceById("inputText2");
|
||||||
inst.elm.focus();
|
inst.elm.focus();
|
||||||
@ -104,7 +104,7 @@ mindplot.RichTextEditor = mindplot.TextEditor.extend({
|
|||||||
var text = this._text;
|
var text = this._text;
|
||||||
this._text = this._editor.instanceById("inputText2").getContent();
|
this._text = this._editor.instanceById("inputText2").getContent();
|
||||||
if(text!=this._text){
|
if(text!=this._text){
|
||||||
this.applyChanges = true;
|
this._applyChanges = true;
|
||||||
}
|
}
|
||||||
console.log('bye');
|
console.log('bye');
|
||||||
this.lostFocusListener();
|
this.lostFocusListener();
|
||||||
@ -124,11 +124,11 @@ mindplot.RichTextEditor = mindplot.TextEditor.extend({
|
|||||||
this._hideNode();
|
this._hideNode();
|
||||||
if (this._currentNode != null)
|
if (this._currentNode != null)
|
||||||
{
|
{
|
||||||
if(this.applyChanges)
|
if(this._applyChanges)
|
||||||
{
|
{
|
||||||
this._updateNode();
|
this._updateModel();
|
||||||
}
|
}
|
||||||
this.applyChanges=true;
|
this._applyChanges=true;
|
||||||
this._currentNode = null;
|
this._currentNode = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -25,6 +25,9 @@ mindplot.ScreenManager = new Class({
|
|||||||
// Ignore default click event propagation. Prevent 'click' event on drad.
|
// Ignore default click event propagation. Prevent 'click' event on drad.
|
||||||
this._clickEvents = [];
|
this._clickEvents = [];
|
||||||
this._divContainer.addEvent('click',function(event){event.stopPropagation()});
|
this._divContainer.addEvent('click',function(event){event.stopPropagation()});
|
||||||
|
|
||||||
|
// @Todo: This must be resolved in other way ...
|
||||||
|
mindplot.util.Converter.setScreenManager(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
setScale : function(scale) {
|
setScale : function(scale) {
|
||||||
@ -59,7 +62,7 @@ mindplot.ScreenManager = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getWorkspaceElementPosition : function(e) {
|
getWorkspaceElementPosition : function(e) {
|
||||||
// Retrive current element position.
|
// Retrieve current element position.
|
||||||
var elementPosition = e.getPosition();
|
var elementPosition = e.getPosition();
|
||||||
var x = elementPosition.x;
|
var x = elementPosition.x;
|
||||||
var y = elementPosition.y;
|
var y = elementPosition.y;
|
||||||
@ -68,16 +71,10 @@ mindplot.ScreenManager = new Class({
|
|||||||
x = x - this._offset.x;
|
x = x - this._offset.x;
|
||||||
y = y - this._offset.y;
|
y = y - this._offset.y;
|
||||||
|
|
||||||
// Scale coordinate in order to be relative to the workspace. That's coordSize/size;
|
// Scale coordinate in order to be relative to the workspace. That's coord/size;
|
||||||
x = x / this._workspaceScale;
|
x = x / this._workspaceScale;
|
||||||
y = y / this._workspaceScale;
|
y = y / this._workspaceScale;
|
||||||
|
|
||||||
// Subtract div position.
|
|
||||||
/* var containerElem = this.getContainer();
|
|
||||||
var containerPosition = core.Utils.workOutDivElementPosition(containerElem);
|
|
||||||
x = x + containerPosition.x;
|
|
||||||
y = y + containerPosition.y;*/
|
|
||||||
|
|
||||||
// Remove decimal part..
|
// Remove decimal part..
|
||||||
return {x:x,y:y};
|
return {x:x,y:y};
|
||||||
},
|
},
|
||||||
|
@ -17,209 +17,176 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.TextEditor = new Class({
|
mindplot.TextEditor = new Class({
|
||||||
initialize:function(designer) {
|
initialize:function(topic) {
|
||||||
this._designer = designer;
|
this._topic = topic;
|
||||||
this._screenManager = designer.getWorkSpace().getScreenManager();
|
|
||||||
this._container = this._screenManager.getContainer();
|
|
||||||
this._isVisible = false;
|
|
||||||
|
|
||||||
//Create editor ui
|
|
||||||
this._createUI();
|
|
||||||
|
|
||||||
this._addListeners();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_createUI:function() {
|
_buildEditor : function() {
|
||||||
|
|
||||||
this._size = {width:500, height:100};
|
this._size = {width:500, height:100};
|
||||||
this._myOverlay = new Element('div').setStyles({position:"absolute", display: "none", zIndex: "8", top: 0, left:0, width:"500px", height:"100px"});
|
var result = new Element('div');
|
||||||
var inputContainer = new Element('div').setStyles({border:"none", overflow:"auto"}).inject(this._myOverlay);
|
result.setStyles({
|
||||||
this.inputText = new Element('input').setProperties({type:"text", tabindex:'-1', id:"inputText", value:""}).setStyles({border:"none", background:"transparent"}).inject(inputContainer);
|
position:"absolute",
|
||||||
var spanContainer = new Element('div').setStyle('visibility', "hidden").inject(this._myOverlay);
|
display: "none",
|
||||||
this._spanText = new Element('span').setProperties({id: "spanText", tabindex:"-1"}).setStyle('white-space', "nowrap").setStyle('nowrap', 'nowrap').inject(spanContainer);
|
zIndex: "8",
|
||||||
this._myOverlay.inject(this._container);
|
top: 0,
|
||||||
|
left:0,
|
||||||
|
width:"500px",
|
||||||
|
height:"100px"}
|
||||||
|
);
|
||||||
|
|
||||||
|
var inputContainer = new Element('div');
|
||||||
|
inputContainer.setStyles({
|
||||||
|
border:"none",
|
||||||
|
overflow:"auto"});
|
||||||
|
inputContainer.inject(result);
|
||||||
|
|
||||||
|
var inputText = new Element('input', {type:"text",tabindex:'-1', value:""});
|
||||||
|
inputText.setStyles({
|
||||||
|
border:"none",
|
||||||
|
background:"transparent"
|
||||||
|
});
|
||||||
|
inputText.inject(inputContainer);
|
||||||
|
|
||||||
|
var spanContainer = new Element('div');
|
||||||
|
spanContainer.setStyle('visibility', "hidden");
|
||||||
|
spanContainer.inject(result);
|
||||||
|
|
||||||
|
var spanElem = new Element('span', {tabindex:"-1"});
|
||||||
|
spanElem.setStyle('white-space', "nowrap");
|
||||||
|
spanElem.setStyle('nowrap', 'nowrap');
|
||||||
|
spanElem.inject(spanContainer);
|
||||||
|
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
_addListeners:function() {
|
_registerEvents : function(divElem) {
|
||||||
var elem = this;
|
var inputElem = this._getInputElem();
|
||||||
this.applyChanges = true;
|
var spanElem = this._getSpanElem();
|
||||||
this.inputText.onkeyup = function (evt) {
|
|
||||||
var event = new Event(evt);
|
|
||||||
var key = event.key;
|
|
||||||
switch (key) {
|
|
||||||
case 'esc':
|
|
||||||
elem.applyChanges = false;
|
|
||||||
case 'enter':
|
|
||||||
var executor = function(editor) {
|
|
||||||
return function() {
|
|
||||||
elem.lostFocus(true);
|
|
||||||
$(document.documentElement).fireEvent('focus');
|
|
||||||
};
|
|
||||||
};
|
|
||||||
setTimeout(executor(this), 3);
|
|
||||||
|
|
||||||
|
divElem.addEvent('keydown', function (event) {
|
||||||
|
switch (event.key) {
|
||||||
|
case 'esc':
|
||||||
|
this.close(false);
|
||||||
|
break;
|
||||||
|
case 'enter':
|
||||||
|
this.close(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
var span = $('spanText');
|
spanElem.innerHTML = inputElem.value;
|
||||||
var input = $('inputText');
|
var size = inputElem.value.length + 1;
|
||||||
span.innerHTML = input.value;
|
inputElem.size = size;
|
||||||
var size = input.value.length + 1;
|
if (spanElem.offsetWidth > (parseInt(divElem.style.width) - 100)) {
|
||||||
input.size = size;
|
divElem.style.width = (spanElem.offsetWidth + 100) + "px";
|
||||||
if (span.offsetWidth > (parseInt(elem._myOverlay.style.width) - 100)) {
|
|
||||||
elem._myOverlay.style.width = (span.offsetWidth + 100) + "px";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
event.stopPropagation();
|
||||||
//Register onLostFocus/onBlur event
|
}.bind(this));
|
||||||
$(this.inputText).addEvent('blur', this.lostFocusEvent.bind(this));
|
|
||||||
$(this._myOverlay).addEvent('click', this.clickEvent.bindWithEvent(this));
|
|
||||||
$(this._myOverlay).addEvent('dblclick', this.clickEvent.bindWithEvent(this));
|
|
||||||
$(this._myOverlay).addEvent('mousedown', this.mouseDownEvent.bindWithEvent(this));
|
|
||||||
|
|
||||||
var elem = this;
|
// If the user clicks on the input, all event must be ignored ...
|
||||||
var onComplete = function() {
|
divElem.addEvent('click', function(event) {
|
||||||
this._myOverlay.setStyle('display', "none");
|
event.stopPropagation();
|
||||||
this._isVisible = false;
|
});
|
||||||
this.inputText.setStyle('opacity', 1);
|
divElem.addEvent('dblclick', function(event) {
|
||||||
|
event.stopPropagation();
|
||||||
this.setPosition(0, 0);
|
});
|
||||||
if (elem._currentNode != null) {
|
divElem.addEvent('mousedown', function(event) {
|
||||||
this._currentNode.getTextShape().setVisibility(true);
|
event.stopPropagation();
|
||||||
if (this.applyChanges) {
|
});
|
||||||
this._updateNode();
|
|
||||||
}
|
|
||||||
this.applyChanges = true;
|
|
||||||
this._currentNode = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout("$('ffoxWorkarroundInput').focus();", 0);
|
|
||||||
};
|
|
||||||
this.fx = new Fx.Tween(this.inputText, {property: 'opacity', duration: 10});
|
|
||||||
this.fx.addEvent('onComplete', onComplete.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
lostFocusEvent : function () {
|
|
||||||
this.fx.options.duration = 10;
|
|
||||||
this.fx.start(1, 0);
|
|
||||||
//myAnim.animate();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isVisible : function () {
|
isVisible : function () {
|
||||||
return this._isVisible;
|
return $defined(this._divElem) && this._divElem.getStyle('display') == 'block';
|
||||||
},
|
},
|
||||||
|
|
||||||
getFocusEvent: function (node) {
|
_updateModel : function () {
|
||||||
//console.log('focus event');
|
|
||||||
if (this.isVisible()) {
|
|
||||||
this.getFocusEvent.delay(10, this);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//console.log('calling init');
|
|
||||||
this.init(node);
|
|
||||||
}
|
|
||||||
//console.log('focus event done');
|
|
||||||
},
|
|
||||||
|
|
||||||
setInitialText : function (text) {
|
if (this._topic.getText() != this._getText()) {
|
||||||
this.initialText = text;
|
var text = this._getText();
|
||||||
},
|
var topicId = this._topic.getId();
|
||||||
|
|
||||||
_updateNode : function () {
|
|
||||||
|
|
||||||
if ($defined(this._currentNode) && this._currentNode.getText() != this.getText()) {
|
|
||||||
var text = this.getText();
|
|
||||||
var topicId = this._currentNode.getId();
|
|
||||||
|
|
||||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||||
actionDispatcher.changeTextOnTopic([topicId], text);
|
actionDispatcher.changeTextOnTopic([topicId], text);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
listenEventOnNode : function(topic, eventName, stopPropagation) {
|
show : function (text) {
|
||||||
var elem = this;
|
|
||||||
topic.addEventListener(eventName, function (event) {
|
|
||||||
if (elem._designer.getWorkSpace().isWorkspaceEventsEnabled()) {
|
|
||||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMouseOutEvent, [topic ]);
|
|
||||||
elem.lostFocus();
|
|
||||||
elem.getFocusEvent.attempt(topic, elem);
|
|
||||||
|
|
||||||
if (stopPropagation) {
|
if (!this.isVisible()) {
|
||||||
if ($defined(event.stopPropagation)) {
|
//Create editor ui
|
||||||
event.stopPropagation(true);
|
var editorElem = this._buildEditor();
|
||||||
} else {
|
// @Todo: What element associate ?
|
||||||
event.cancelBubble = true;
|
editorElem.inject($('mindplot'));
|
||||||
|
|
||||||
|
this._divElem = editorElem;
|
||||||
|
this._registerEvents(editorElem);
|
||||||
|
this._showEditor(text);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
init : function (nodeGraph) {
|
_showEditor : function (defaultText) {
|
||||||
//console.log('init method');
|
|
||||||
nodeGraph.getTextShape().setVisibility(false);
|
|
||||||
this._currentNode = nodeGraph;
|
|
||||||
|
|
||||||
//set Editor Style
|
var topic = this._topic;
|
||||||
var nodeText = nodeGraph.getTextShape();
|
|
||||||
var text;
|
|
||||||
var selectText = true;
|
|
||||||
if (this.initialText && this.initialText != "") {
|
|
||||||
text = this.initialText;
|
|
||||||
this.initialText = null;
|
|
||||||
selectText = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
text = nodeText.getText();
|
|
||||||
|
|
||||||
|
// Hide topic text ...
|
||||||
|
topic.getTextShape().setVisibility(false);
|
||||||
|
|
||||||
|
// Set Editor Style
|
||||||
|
var nodeText = topic.getTextShape();
|
||||||
var font = nodeText.getFont();
|
var font = nodeText.getFont();
|
||||||
font.size = nodeText.getHtmlFontSize();
|
font.size = nodeText.getHtmlFontSize();
|
||||||
font.color = nodeText.getColor();
|
font.color = nodeText.getColor();
|
||||||
|
this._setStyle(font);
|
||||||
|
|
||||||
this.setStyle(font);
|
// Set editor's initial text
|
||||||
|
var text = $defined(defaultText) ? defaultText : topic.getText();
|
||||||
|
this._setText(text);
|
||||||
|
|
||||||
//set editor's initial text
|
// Set editor's initial size
|
||||||
this.setText(text);
|
var displayFunc = function() {
|
||||||
|
var textShape = topic.getTextShape();
|
||||||
|
var scale = web2d.peer.utils.TransformUtil.workoutScale(textShape._peer);
|
||||||
|
|
||||||
//set editor's initial size
|
var screenPosition = mindplot.util.Converter.topicToScreenPosition(topic);
|
||||||
var editor = this;
|
var textWidth = textShape.getWidth();
|
||||||
var executor = function(editor) {
|
var textHeight = textShape.getHeight();
|
||||||
return function() {
|
var iconGroup = topic.getIconGroup();
|
||||||
//console.log('setting editor in init thread');
|
|
||||||
var scale = web2d.peer.utils.TransformUtil.workoutScale(editor._currentNode.getTextShape()._peer);
|
|
||||||
var elemSize = editor._currentNode.getSize();
|
|
||||||
//var textSize = editor.getSize();
|
|
||||||
var pos = editor._screenManager.getWorkspaceElementPosition(editor._currentNode);
|
|
||||||
|
|
||||||
var textWidth = editor._currentNode.getTextShape().getWidth();
|
|
||||||
var textHeight = editor._currentNode.getTextShape().getHeight();
|
|
||||||
var iconGroup = editor._currentNode.getIconGroup();
|
|
||||||
var iconGroupSize;
|
var iconGroupSize;
|
||||||
|
|
||||||
if ($defined(iconGroup)) {
|
if ($defined(iconGroup)) {
|
||||||
iconGroupSize = editor._currentNode.getIconGroup().getSize();
|
iconGroupSize = topic.getIconGroup().getSize();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
iconGroupSize = {width:0, height:0};
|
iconGroupSize = {width:0, height:0};
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = {x:0,y:0};
|
var position = {x:0,y:0};
|
||||||
position.x = pos.x - ((textWidth * scale.width) / 2) + (((iconGroupSize.width) * scale.width) / 2);
|
position.x = screenPosition.x - ((textWidth * scale.width) / 2) + (((iconGroupSize.width) * scale.width) / 2);
|
||||||
var fixError = 1;
|
var fixError = 1;
|
||||||
position.y = pos.y - ((textHeight * scale.height) / 2) - fixError;
|
position.y = screenPosition.y - ((textHeight * scale.height) / 2) - fixError;
|
||||||
|
|
||||||
editor.setEditorSize(elemSize.width, elemSize.height, scale);
|
var elemSize = topic.getSize();
|
||||||
//console.log('setting position:'+pos.x+';'+pos.y);
|
|
||||||
editor.setPosition(position.x, position.y, scale);
|
|
||||||
editor.showTextEditor(selectText);
|
|
||||||
//console.log('setting editor done');
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
setTimeout(executor(this), 10);
|
// Position the editor and set the size...
|
||||||
|
this._setEditorSize(elemSize.width, elemSize.height, scale);
|
||||||
|
this._setPosition(position.x, position.y, scale);
|
||||||
|
|
||||||
|
// Make the editor visible ....
|
||||||
|
this._divElem.setStyle('display', 'block');
|
||||||
|
|
||||||
|
var inputElem = this._getInputElem();
|
||||||
|
inputElem.focus();
|
||||||
|
this._changeCursor(inputElem, $defined(defaultText));
|
||||||
|
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
displayFunc.delay(10);
|
||||||
},
|
},
|
||||||
|
|
||||||
setStyle : function (fontStyle) {
|
_setStyle : function (fontStyle) {
|
||||||
var inputField = $("inputText");
|
var inputField = this._getInputElem();
|
||||||
var spanField = $("spanText");
|
var spanField = this._getSpanElem();
|
||||||
if (!$defined(fontStyle.font)) {
|
if (!$defined(fontStyle.font)) {
|
||||||
fontStyle.font = "Arial";
|
fontStyle.font = "Arial";
|
||||||
}
|
}
|
||||||
@ -243,58 +210,48 @@ mindplot.TextEditor = new Class({
|
|||||||
spanField.style.fontSize = fontStyle.size + "px";
|
spanField.style.fontSize = fontStyle.size + "px";
|
||||||
},
|
},
|
||||||
|
|
||||||
setText : function(text) {
|
_setText : function(text) {
|
||||||
var inputField = $("inputText");
|
var inputField = this._getInputElem();
|
||||||
inputField.size = text.length + 1;
|
inputField.size = text.length + 1;
|
||||||
//this._myOverlay.cfg.setProperty("width", (inputField.size * parseInt(inputField.style.fontSize) + 100) + "px");
|
this._divElem.style.width = (inputField.size * parseInt(inputField.style.fontSize) + 100) + "px";
|
||||||
this._myOverlay.style.width = (inputField.size * parseInt(inputField.style.fontSize) + 100) + "px";
|
var spanField = this._getSpanElem();
|
||||||
var spanField = $("spanText");
|
|
||||||
spanField.innerHTML = text;
|
spanField.innerHTML = text;
|
||||||
inputField.value = text;
|
inputField.value = text;
|
||||||
},
|
},
|
||||||
|
|
||||||
getText : function() {
|
_getText : function() {
|
||||||
return $('inputText').value;
|
return this._getInputElem().value;
|
||||||
},
|
},
|
||||||
|
|
||||||
setEditorSize : function (width, height, scale) {
|
_getInputElem : function() {
|
||||||
//var scale = web2d.peer.utils.TransformUtil.workoutScale(this._currentNode.getTextShape()._peer);
|
return this._divElem.getElement('input');
|
||||||
|
},
|
||||||
|
|
||||||
|
_getSpanElem : function() {
|
||||||
|
return this._divElem.getElement('span');
|
||||||
|
},
|
||||||
|
|
||||||
|
_setEditorSize : function (width, height, scale) {
|
||||||
this._size = {width:width * scale.width, height:height * scale.height};
|
this._size = {width:width * scale.width, height:height * scale.height};
|
||||||
//this._myOverlay.cfg.setProperty("width",this._size.width*2+"px");
|
this._divElem.style.width = this._size.width * 2 + "px";
|
||||||
this._myOverlay.style.width = this._size.width * 2 + "px";
|
this._divElem.style.height = this._size.height + "px";
|
||||||
//this._myOverlay.cfg.setProperty("height",this._size.height+"px");
|
|
||||||
this._myOverlay.style.height = this._size.height + "px";
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getSize : function () {
|
_setPosition : function (x, y) {
|
||||||
return {width:$("spanText").offsetWidth,height:$("spanText").offsetHeight};
|
$(this._divElem).setStyles({top : y + "px", left: x + "px"});
|
||||||
},
|
},
|
||||||
|
|
||||||
setPosition : function (x, y, scale) {
|
_showTextElem : function(selectText) {
|
||||||
$(this._myOverlay).setStyles({top : y + "px", left: x + "px"});
|
|
||||||
//this._myOverlay.style.left = x + "px";
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showTextEditor : function(selectText) {
|
_changeCursor : function(inputElem, selectText) {
|
||||||
//this._myOverlay.show();
|
// Select text if it's required ...
|
||||||
//var myAnim = new YAHOO.util.Anim('inputText',{opacity: {to:1}}, 0.10, YAHOO.util.Easing.easeOut);
|
if (inputElem.createTextRange) //ie
|
||||||
//$('inputText').style.opacity='1';
|
|
||||||
var elem = this;
|
|
||||||
//myAnim.onComplete.subscribe(function(){
|
|
||||||
//elem._myOverlay.show();
|
|
||||||
elem._myOverlay.setStyle('display', "block");
|
|
||||||
this._isVisible = true;
|
|
||||||
//elem.cfg.setProperty("visible", false);
|
|
||||||
//elem._myOverlay.cfg.setProperty("xy", [0, 0]);
|
|
||||||
//elem._myOverlay.cfg.setProperty("visible", true);
|
|
||||||
//select the text in the input
|
|
||||||
$('inputText').disabled = false;
|
|
||||||
|
|
||||||
if ($('inputText').createTextRange) //ie
|
|
||||||
{
|
{
|
||||||
var range = $('inputText').createTextRange();
|
var range = inputElem.createTextRange();
|
||||||
var pos = $('inputText').value.length;
|
var pos = inputElem.value.length;
|
||||||
if (selectText) {
|
if (!selectText) {
|
||||||
range.select();
|
range.select();
|
||||||
range.move("character", pos);
|
range.move("character", pos);
|
||||||
}
|
}
|
||||||
@ -303,53 +260,26 @@ mindplot.TextEditor = new Class({
|
|||||||
range.select();
|
range.select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (selectText) {
|
else if (!selectText) {
|
||||||
$('inputText').setSelectionRange(0, $('inputText').value.length);
|
inputElem.setSelectionRange(0, inputElem.value.length);
|
||||||
}
|
|
||||||
|
|
||||||
var executor = function(editor) {
|
|
||||||
return function() {
|
|
||||||
try {
|
|
||||||
$('inputText').focus();
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
setTimeout(executor(this), 0);
|
|
||||||
//});
|
|
||||||
//myAnim.animate();
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
lostFocus : function(bothBrowsers) {
|
|
||||||
if (this.isVisible()) {
|
|
||||||
//the editor is opened in another node. lets Finish it.
|
|
||||||
var fireOnThis = $('inputText');
|
|
||||||
fireOnThis.fireEvent('blur');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clickEvent : function(event) {
|
|
||||||
|
close : function(update) {
|
||||||
if (this.isVisible()) {
|
if (this.isVisible()) {
|
||||||
if ($defined(event.stopPropagation)) {
|
|
||||||
event.stopPropagation(true);
|
// Update changes ...
|
||||||
} else {
|
if (!$defined(update) || update) {
|
||||||
event.cancelBubble = true;
|
this._updateModel();
|
||||||
}
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
// Let make the visible text in the node visible again ...
|
||||||
mouseDownEvent : function(event) {
|
this._topic.getTextShape().setVisibility(true);
|
||||||
if (this.isVisible()) {
|
|
||||||
if ($defined(event.stopPropagation)) {
|
|
||||||
event.stopPropagation(true);
|
|
||||||
} else {
|
|
||||||
event.cancelBubble = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Remove it form the screen ...
|
||||||
|
this._divElem.dispose();
|
||||||
|
this._divElem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,9 +26,7 @@ mindplot.Topic = new Class({
|
|||||||
this._relationships = [];
|
this._relationships = [];
|
||||||
this._isInWorkspace = false;
|
this._isInWorkspace = false;
|
||||||
this._helpers = [];
|
this._helpers = [];
|
||||||
|
|
||||||
this._buildShape();
|
this._buildShape();
|
||||||
this.setMouseEventsEnabled(true);
|
|
||||||
|
|
||||||
// Position a topic ....
|
// Position a topic ....
|
||||||
var pos = model.getPosition();
|
var pos = model.getPosition();
|
||||||
@ -36,15 +34,31 @@ mindplot.Topic = new Class({
|
|||||||
this.setPosition(pos);
|
this.setPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.registerEvents();
|
// Register events for the topic ...
|
||||||
|
this._registerEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
registerEvents:function () {
|
_registerEvents : function() {
|
||||||
|
|
||||||
|
this.setMouseEventsEnabled(true);
|
||||||
|
|
||||||
// Prevent click on the topics being propagated ...
|
// Prevent click on the topics being propagated ...
|
||||||
this.addEventListener('click', function(event) {
|
this.addEventListener('click', function(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addEventListener('dblclick', function (event) {
|
||||||
|
this._textEditor.show();
|
||||||
|
event.stopPropagation(true);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
this.addEventListener('keydown', function(event) {
|
||||||
|
if (this.isOnFocus()) {
|
||||||
|
this._textEditor.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setShapeType : function(type) {
|
setShapeType : function(type) {
|
||||||
|
@ -64,7 +64,7 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register editor events ...
|
// Register editor events ...
|
||||||
if (!$defined(this.getDesigner()._viewMode)|| ($defined(this.getDesigner()._viewMode) && !this.getDesigner()._viewMode))
|
if (!$defined(this.getDesigner()._readOnly)|| ($defined(this.getDesigner()._readOnly) && !this.getDesigner()._readOnly))
|
||||||
{
|
{
|
||||||
this.getDesigner()._editor.listenEventOnNode(topic, 'dblclick', true);
|
this.getDesigner()._editor.listenEventOnNode(topic, 'dblclick', true);
|
||||||
}
|
}
|
||||||
|
@ -135,12 +135,6 @@ mindplot.layout.OriginalLayoutManager = new Class({
|
|||||||
var dragger = this._dragger;
|
var dragger = this._dragger;
|
||||||
dragger.add(topic);
|
dragger.add(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register editor events ...
|
|
||||||
if (!$defined(this.getDesigner()._viewMode) || ($defined(this.getDesigner()._viewMode) && !this.getDesigner()._viewMode)) {
|
|
||||||
this.getDesigner()._editor.listenEventOnNode(topic, 'dblclick', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_createMainTopicBoard:function(node) {
|
_createMainTopicBoard:function(node) {
|
||||||
|
@ -183,9 +183,6 @@ mindplot.model.NodeModel = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setPosition : function(x, y) {
|
setPosition : function(x, y) {
|
||||||
$assert(x, "x coordinate must be defined");
|
|
||||||
$assert(y, "y coordinate must be defined");
|
|
||||||
|
|
||||||
if (!$defined(this._position)) {
|
if (!$defined(this._position)) {
|
||||||
this._position = new core.Point();
|
this._position = new core.Point();
|
||||||
}
|
}
|
||||||
|
31
mindplot/src/main/javascript/util/Converter.js
Normal file
31
mindplot/src/main/javascript/util/Converter.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.util.Converter = {
|
||||||
|
|
||||||
|
topicToScreenPosition : function(topic) {
|
||||||
|
$assert(topic, "topic is not defined");
|
||||||
|
$assert(this._screenManager, "screenManager is not defined");
|
||||||
|
|
||||||
|
return this._screenManager.getWorkspaceElementPosition(topic);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mindplot.util.Converter.setScreenManager = function(instance) {
|
||||||
|
this._screenManager = instance;
|
||||||
|
};
|
@ -18,25 +18,13 @@
|
|||||||
|
|
||||||
mindplot.util.Shape =
|
mindplot.util.Shape =
|
||||||
{
|
{
|
||||||
isAtRight: function(sourcePoint, targetPoint)
|
isAtRight: function(sourcePoint, targetPoint) {
|
||||||
{
|
|
||||||
$assert(sourcePoint, "Source can not be null");
|
$assert(sourcePoint, "Source can not be null");
|
||||||
$assert(targetPoint, "Target can not be null");
|
$assert(targetPoint, "Target can not be null");
|
||||||
return sourcePoint.x < targetPoint.x;
|
return sourcePoint.x < targetPoint.x;
|
||||||
},
|
},
|
||||||
workoutDistance: function(sourceNode, targetNode)
|
|
||||||
{
|
|
||||||
var sPos = sourceNode.getPosition();
|
|
||||||
var tPos = targetNode.getPosition();
|
|
||||||
|
|
||||||
var x = tPos.x - sPos.x;
|
calculateRectConnectionPoint: function(rectCenterPoint, rectSize, isAtRight) {
|
||||||
var y = tPos.y - sPos.y;
|
|
||||||
|
|
||||||
var hip = y * y + x * x;
|
|
||||||
return hip;
|
|
||||||
},
|
|
||||||
calculateRectConnectionPoint: function(rectCenterPoint, rectSize, isAtRight)
|
|
||||||
{
|
|
||||||
$assert(rectCenterPoint, 'rectCenterPoint can not be null');
|
$assert(rectCenterPoint, 'rectCenterPoint can not be null');
|
||||||
$assert(rectSize, 'rectSize can not be null');
|
$assert(rectSize, 'rectSize can not be null');
|
||||||
$assert(isAtRight, 'isRight can not be null');
|
$assert(isAtRight, 'isRight can not be null');
|
||||||
@ -46,98 +34,12 @@ mindplot.util.Shape =
|
|||||||
|
|
||||||
// This is used fix a minor difference ...z
|
// This is used fix a minor difference ...z
|
||||||
var correctionHardcode = 2;
|
var correctionHardcode = 2;
|
||||||
if (isAtRight)
|
if (isAtRight) {
|
||||||
{
|
|
||||||
result.setValue(rectCenterPoint.x - (rectSize.width / 2) + correctionHardcode, rectCenterPoint.y);
|
result.setValue(rectCenterPoint.x - (rectSize.width / 2) + correctionHardcode, rectCenterPoint.y);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
result.setValue(parseFloat(rectCenterPoint.x) + (rectSize.width / 2) - correctionHardcode, rectCenterPoint.y);
|
result.setValue(parseFloat(rectCenterPoint.x) + (rectSize.width / 2) - correctionHardcode, rectCenterPoint.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
_getRectShapeOffset : function(sourceTopic, targetTopic)
|
|
||||||
{
|
|
||||||
|
|
||||||
var tPos = targetTopic.getPosition();
|
|
||||||
var sPos = sourceTopic.getPosition();
|
|
||||||
|
|
||||||
var tSize = targetTopic.getSize();
|
|
||||||
|
|
||||||
var x = sPos.x - tPos.x;
|
|
||||||
var y = sPos.y - tPos.y;
|
|
||||||
|
|
||||||
var gradient = 0;
|
|
||||||
if ($defined(x))
|
|
||||||
{
|
|
||||||
gradient = y / x;
|
|
||||||
}
|
|
||||||
|
|
||||||
var area = this._getSector(gradient, x, y);
|
|
||||||
var xOff = -1;
|
|
||||||
var yOff = -1;
|
|
||||||
if (area == 1 || area == 3)
|
|
||||||
{
|
|
||||||
xOff = tSize.width / 2;
|
|
||||||
yOff = xOff * gradient;
|
|
||||||
|
|
||||||
xOff = xOff * ((x < 0) ? -1 : 1);
|
|
||||||
yOff = yOff * ((x < 0) ? -1 : 1);
|
|
||||||
|
|
||||||
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
yOff = tSize.height / 2;
|
|
||||||
xOff = yOff / gradient;
|
|
||||||
|
|
||||||
yOff = yOff * ((y < 0) ? -1 : 1);
|
|
||||||
xOff = xOff * ((y < 0) ? -1 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Controll boundaries.
|
|
||||||
if (Math.abs(xOff) > tSize.width / 2)
|
|
||||||
{
|
|
||||||
xOff = ((tSize.width / 2) * Math.sign(xOff));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Math.abs(yOff) > tSize.height / 2)
|
|
||||||
{
|
|
||||||
yOff = ((tSize.height / 2) * Math.sign(yOff));
|
|
||||||
}
|
|
||||||
|
|
||||||
return {x:xOff,y:yOff};
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sector are numered following the clockwise direction.
|
|
||||||
*/
|
|
||||||
_getSector : function(gradient, x, y)
|
|
||||||
{
|
|
||||||
var result;
|
|
||||||
if (gradient < 0.5 && gradient > -0.5)
|
|
||||||
{
|
|
||||||
// Sector 1 and 3
|
|
||||||
if (x >= 0)
|
|
||||||
{
|
|
||||||
result = 1;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
result = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
// Sector 2 and 4
|
|
||||||
if (y <= 0)
|
|
||||||
{
|
|
||||||
result = 4;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
result = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -198,7 +198,7 @@
|
|||||||
|
|
||||||
<div id="footerEditor">
|
<div id="footerEditor">
|
||||||
<div style="position:absolute; top:0px; width:100%">
|
<div style="position:absolute; top:0px; width:100%">
|
||||||
<a href="home.htm">
|
<a href="http://www.wisemapping.com/">
|
||||||
<div id="logo"></div>
|
<div id="logo"></div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@ -215,7 +215,6 @@
|
|||||||
<div style="float:left; position:relative; top:50%; margin-top:-8px; margin-left:4px;">Shortcuts</div>
|
<div style="float:left; position:relative; top:50%; margin-top:-8px; margin-left:4px;">Shortcuts</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="ffoxworkarround" style="display:none;"><input id="ffoxWorkarroundInput" type="text"></div>
|
|
||||||
<script type="text/javascript" src="../js/editor.js"></script>
|
<script type="text/javascript" src="../js/editor.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -150,8 +150,6 @@ Tabs.Init();
|
|||||||
// Hide the content while waiting for the onload event to trigger.
|
// Hide the content while waiting for the onload event to trigger.
|
||||||
var contentId = window.location.hash || "#Introduction";
|
var contentId = window.location.hash || "#Introduction";
|
||||||
|
|
||||||
var iconPanel = null;
|
|
||||||
|
|
||||||
function afterMindpotLibraryLoading() {
|
function afterMindpotLibraryLoading() {
|
||||||
buildMindmapDesigner();
|
buildMindmapDesigner();
|
||||||
|
|
||||||
@ -177,16 +175,6 @@ function afterMindpotLibraryLoading() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Key Events ...
|
|
||||||
$(document).addEvent('keydown', designer.keyEventHandler.bind(designer));
|
|
||||||
$("ffoxWorkarroundInput").addEvent('keydown', designer.keyEventHandler.bind(designer));
|
|
||||||
|
|
||||||
// To prevent the user from leaving the page with changes ...
|
|
||||||
window.onbeforeunload = function () {
|
|
||||||
if (designer.needsSave()) {
|
|
||||||
designer.save(null, false)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var menu = new mindplot.widget.Menu(designer, 'toolbar');
|
var menu = new mindplot.widget.Menu(designer, 'toolbar');
|
||||||
|
|
||||||
// If a node has focus, focus can be move to another node using the keys.
|
// If a node has focus, focus can be move to another node using the keys.
|
||||||
@ -194,14 +182,12 @@ function afterMindpotLibraryLoading() {
|
|||||||
menu.clear()
|
menu.clear()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// If not problem has arisen, close the dialog ...
|
// If not problem has arisen, close the dialog ...
|
||||||
var closeDialog = function() {
|
(function() {
|
||||||
|
|
||||||
if (!window.hasUnexpectedErrors) {
|
if (!window.hasUnexpectedErrors) {
|
||||||
waitDialog.deactivate();
|
waitDialog.deactivate();
|
||||||
}
|
}
|
||||||
}.delay(500);
|
}).delay(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildMindmapDesigner() {
|
function buildMindmapDesigner() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// MooTools: the javascript framework.
|
// MooTools: the javascript framework.
|
||||||
// Load this file's selection again by visiting: http://mootools.net/more/979a28b1cc76ab15b6da1704eb6e4c2c
|
// Load this file's selection again by visiting: http://mootools.net/more/62b5cf1c687ec9e067cb5d1c933b608f
|
||||||
// Or build this file again with packager using: packager build More/More More/String.Extras More/URI More/URI.Relative More/Hash More/Hash.Extras More/Fx.Elements More/Fx.Accordion More/Fx.Move More/Fx.Reveal More/Fx.Scroll More/Fx.Slide More/Fx.SmoothScroll More/Fx.Sort More/Drag More/Drag.Move More/Assets More/Color More/Locale
|
// Or build this file again with packager using: packager build More/More More/String.Extras More/URI More/URI.Relative More/Hash More/Hash.Extras More/Fx.Elements More/Fx.Accordion More/Fx.Move More/Fx.Reveal More/Fx.Scroll More/Fx.Slide More/Fx.SmoothScroll More/Fx.Sort More/Drag More/Drag.Move More/Assets More/Color More/Keyboard More/Keyboard.Extras More/Locale
|
||||||
/*
|
/*
|
||||||
---
|
---
|
||||||
copyrights:
|
copyrights:
|
||||||
@ -72,21 +72,17 @@ if(e&&!this.selfHidden){for(var d in f){e.setStyle(d,e[f[d]]);}}}if((this.timer&
|
|||||||
this.selfHidden=false;g.each(function(l,k){h[k]={};var j;if(k!=b){j=true;}else{if(a.alwaysHide&&((l.offsetHeight>0&&a.height)||l.offsetWidth>0&&a.width)){j=true;
|
this.selfHidden=false;g.each(function(l,k){h[k]={};var j;if(k!=b){j=true;}else{if(a.alwaysHide&&((l.offsetHeight>0&&a.height)||l.offsetWidth>0&&a.width)){j=true;
|
||||||
this.selfHidden=true;}}this.fireEvent(j?"background":"active",[this.togglers[k],l]);for(var m in f){h[k][m]=j?0:l[f[m]];}if(!c&&!j&&a.resetHeight){h[k].height="auto";
|
this.selfHidden=true;}}this.fireEvent(j?"background":"active",[this.togglers[k],l]);for(var m in f){h[k][m]=j?0:l[f[m]];}if(!c&&!j&&a.resetHeight){h[k].height="auto";
|
||||||
}},this);this.internalChain.clearChain();this.internalChain.chain(function(){if(a.resetHeight&&!this.selfHidden){var i=g[b];if(i){i.setStyle("height","auto");
|
}},this);this.internalChain.clearChain();this.internalChain.chain(function(){if(a.resetHeight&&!this.selfHidden){var i=g[b];if(i){i.setStyle("height","auto");
|
||||||
}}}.bind(this));return c?this.start(h):this.set(h).internalChain.callChain();}});var Accordion=new Class({Extends:Fx.Accordion,initialize:function(){this.parent.apply(this,arguments);
|
}}}.bind(this));return c?this.start(h):this.set(h).internalChain.callChain();}});(function(){var b=function(e,d){var f=[];Object.each(d,function(g){Object.each(g,function(h){e.each(function(i){f.push(i+"-"+h+(i=="border"?"-width":""));
|
||||||
var a=Array.link(arguments,{container:Type.isElement});this.container=a.container;},addSection:function(c,b,e){c=document.id(c);b=document.id(b);var d=this.togglers.contains(c);
|
|
||||||
var a=this.togglers.length;if(a&&(!d||e)){e=e!=null?e:a-1;c.inject(this.togglers[e],"before");b.inject(c,"after");}else{if(this.container&&!d){c.inject(this.container);
|
|
||||||
b.inject(this.container);}}return this.parent.apply(this,arguments);}});(function(){var b=function(e,d){var f=[];Object.each(d,function(g){Object.each(g,function(h){e.each(function(i){f.push(i+"-"+h+(i=="border"?"-width":""));
|
|
||||||
});});});return f;};var c=function(f,e){var d=0;Object.each(e,function(h,g){if(g.test(f)){d=d+h.toInt();}});return d;};var a=function(d){return !!(!d||d.offsetHeight||d.offsetWidth);
|
});});});return f;};var c=function(f,e){var d=0;Object.each(e,function(h,g){if(g.test(f)){d=d+h.toInt();}});return d;};var a=function(d){return !!(!d||d.offsetHeight||d.offsetWidth);
|
||||||
};Element.implement({measure:function(h){if(a(this)){return h.call(this);}var g=this.getParent(),e=[];while(!a(g)&&g!=document.body){e.push(g.expose());
|
};Element.implement({measure:function(h){if(a(this)){return h.call(this);}var g=this.getParent(),e=[];while(!a(g)&&g!=document.body){e.push(g.expose());
|
||||||
g=g.getParent();}var f=this.expose(),d=h.call(this);f();e.each(function(i){i();});return d;},expose:function(){if(this.getStyle("display")!="none"){return function(){};
|
g=g.getParent();}var f=this.expose(),d=h.call(this);f();e.each(function(i){i();});return d;},expose:function(){if(this.getStyle("display")!="none"){return function(){};
|
||||||
}var d=this.style.cssText;this.setStyles({display:"block",position:"absolute",visibility:"hidden"});return function(){this.style.cssText=d;}.bind(this);
|
}var d=this.style.cssText;this.setStyles({display:"block",position:"absolute",visibility:"hidden"});return function(){this.style.cssText=d;}.bind(this);
|
||||||
},getDimensions:function(d){d=Object.merge({computeSize:false},d);var i={x:0,y:0};var h=function(j,e){return(e.computeSize)?j.getComputedSize(e):j.getSize();
|
},getDimensions:function(d){d=Object.merge({computeSize:false},d);var i={x:0,y:0};var h=function(j,e){return(e.computeSize)?j.getComputedSize(e):j.getSize();
|
||||||
};var f=this.getParent("body");if(f&&this.getStyle("display")=="none"){i=this.measure(function(){return h(this,d);});}else{if(f){try{i=h(this,d);}catch(g){}}}return Object.append(i,(i.x||i.x===0)?{width:i.x,height:i.y}:{x:i.width,y:i.height});
|
};var f=this.getParent("body");if(f&&this.getStyle("display")=="none"){i=this.measure(function(){return h(this,d);});}else{if(f){try{i=h(this,d);}catch(g){}}}return Object.append(i,(i.x||i.x===0)?{width:i.x,height:i.y}:{x:i.width,y:i.height});
|
||||||
},getComputedSize:function(d){if(d&&d.plains){d.planes=d.plains;}d=Object.merge({styles:["padding","border"],planes:{height:["top","bottom"],width:["left","right"]},mode:"both"},d);
|
},getComputedSize:function(d){d=Object.merge({styles:["padding","border"],planes:{height:["top","bottom"],width:["left","right"]},mode:"both"},d);var g={},e={width:0,height:0},f;
|
||||||
var g={},e={width:0,height:0},f;if(d.mode=="vertical"){delete e.width;delete d.planes.width;}else{if(d.mode=="horizontal"){delete e.height;delete d.planes.height;
|
if(d.mode=="vertical"){delete e.width;delete d.planes.width;}else{if(d.mode=="horizontal"){delete e.height;delete d.planes.height;}}b(d.styles,d.planes).each(function(h){g[h]=this.getStyle(h).toInt();
|
||||||
}}b(d.styles,d.planes).each(function(h){g[h]=this.getStyle(h).toInt();},this);Object.each(d.planes,function(i,h){var k=h.capitalize(),j=this.getStyle(h);
|
},this);Object.each(d.planes,function(i,h){var k=h.capitalize(),j=this.getStyle(h);if(j=="auto"&&!f){f=this.getDimensions();}j=g[h]=(j=="auto")?f[h]:j.toInt();
|
||||||
if(j=="auto"&&!f){f=this.getDimensions();}j=g[h]=(j=="auto")?f[h]:j.toInt();e["total"+k]=j;i.each(function(m){var l=c(m,g);e["computed"+m.capitalize()]=l;
|
e["total"+k]=j;i.each(function(m){var l=c(m,g);e["computed"+m.capitalize()]=l;e["total"+k]+=l;});},this);return Object.append(e,g);}});})();(function(b){var a=Element.Position={options:{relativeTo:document.body,position:{x:"center",y:"center"},offset:{x:0,y:0}},getOptions:function(d,c){c=Object.merge({},a.options,c);
|
||||||
e["total"+k]+=l;});},this);return Object.append(e,g);}});})();(function(b){var a=Element.Position={options:{relativeTo:document.body,position:{x:"center",y:"center"},offset:{x:0,y:0}},getOptions:function(d,c){c=Object.merge({},a.options,c);
|
|
||||||
a.setPositionOption(c);a.setEdgeOption(c);a.setOffsetOption(d,c);a.setDimensionsOption(d,c);return c;},setPositionOption:function(c){c.position=a.getCoordinateFromValue(c.position);
|
a.setPositionOption(c);a.setEdgeOption(c);a.setOffsetOption(d,c);a.setDimensionsOption(d,c);return c;},setPositionOption:function(c){c.position=a.getCoordinateFromValue(c.position);
|
||||||
},setEdgeOption:function(d){var c=a.getCoordinateFromValue(d.edge);d.edge=c?c:(d.position.x=="center"&&d.position.y=="center")?{x:"center",y:"center"}:{x:"left",y:"top"};
|
},setEdgeOption:function(d){var c=a.getCoordinateFromValue(d.edge);d.edge=c?c:(d.position.x=="center"&&d.position.y=="center")?{x:"center",y:"center"}:{x:"left",y:"top"};
|
||||||
},setOffsetOption:function(f,d){var c={x:0,y:0},g=f.measure(function(){return document.id(this.getOffsetParent());}),e=g.getScroll();if(!g||g==f.getDocument().body){return;
|
},setOffsetOption:function(f,d){var c={x:0,y:0},g=f.measure(function(){return document.id(this.getOffsetParent());}),e=g.getScroll();if(!g||g==f.getDocument().body){return;
|
||||||
@ -150,8 +146,7 @@ var b=Object.map(document.id(d).getPosition(this.element),function(g,f){return e
|
|||||||
["x","y"].each(function(k){if(g.contains(k)){if(c[k]>h[k]+b[k]){i[k]=c[k]-b[k];}if(f[k]<h[k]){i[k]=f[k];}}if(i[k]==null){i[k]=h[k];}if(e&&e[k]){i[k]=i[k]+e[k];
|
["x","y"].each(function(k){if(g.contains(k)){if(c[k]>h[k]+b[k]){i[k]=c[k]-b[k];}if(f[k]<h[k]){i[k]=f[k];}}if(i[k]==null){i[k]=h[k];}if(e&&e[k]){i[k]=i[k]+e[k];
|
||||||
}},this);if(i.x!=h.x||i.y!=h.y){this.start(i.x,i.y);}return this;},toElementCenter:function(e,f,h){f=f?Array.from(f):["x","y"];e=document.id(e);var i={},c=e.getPosition(this.element),d=e.getSize(),b=this.element.getScroll(),g=this.element.getSize();
|
}},this);if(i.x!=h.x||i.y!=h.y){this.start(i.x,i.y);}return this;},toElementCenter:function(e,f,h){f=f?Array.from(f):["x","y"];e=document.id(e);var i={},c=e.getPosition(this.element),d=e.getSize(),b=this.element.getScroll(),g=this.element.getSize();
|
||||||
["x","y"].each(function(j){if(f.contains(j)){i[j]=c[j]-(g[j]-d[j])/2;}if(i[j]==null){i[j]=b[j];}if(h&&h[j]){i[j]=i[j]+h[j];}},this);if(i.x!=b.x||i.y!=b.y){this.start(i.x,i.y);
|
["x","y"].each(function(j){if(f.contains(j)){i[j]=c[j]-(g[j]-d[j])/2;}if(i[j]==null){i[j]=b[j];}if(h&&h[j]){i[j]=i[j]+h[j];}},this);if(i.x!=b.x||i.y!=b.y){this.start(i.x,i.y);
|
||||||
}return this;}});Fx.Scroll.implement({scrollToCenter:function(){return this.toElementCenter.apply(this,arguments);},scrollIntoView:function(){return this.toElementEdge.apply(this,arguments);
|
}return this;}});function a(b){return(/^(?:body|html)$/i).test(b.tagName);}})();Fx.Slide=new Class({Extends:Fx,options:{mode:"vertical",wrapper:false,hideOverflow:true,resetHeight:false},initialize:function(b,a){b=this.element=this.subject=document.id(b);
|
||||||
}});function a(b){return(/^(?:body|html)$/i).test(b.tagName);}})();Fx.Slide=new Class({Extends:Fx,options:{mode:"vertical",wrapper:false,hideOverflow:true,resetHeight:false},initialize:function(b,a){b=this.element=this.subject=document.id(b);
|
|
||||||
this.parent(a);a=this.options;var d=b.retrieve("wrapper"),c=b.getStyles("margin","position","overflow");if(a.hideOverflow){c=Object.append(c,{overflow:"hidden"});
|
this.parent(a);a=this.options;var d=b.retrieve("wrapper"),c=b.getStyles("margin","position","overflow");if(a.hideOverflow){c=Object.append(c,{overflow:"hidden"});
|
||||||
}if(a.wrapper){d=document.id(a.wrapper).setStyles(c);}if(!d){d=new Element("div",{styles:c}).wraps(b);}b.store("wrapper",d).setStyle("margin",0);if(b.getStyle("overflow")=="visible"){b.setStyle("overflow","hidden");
|
}if(a.wrapper){d=document.id(a.wrapper).setStyles(c);}if(!d){d=new Element("div",{styles:c}).wraps(b);}b.store("wrapper",d).setStyle("margin",0);if(b.getStyle("overflow")=="visible"){b.setStyle("overflow","hidden");
|
||||||
}this.now=[];this.open=true;this.wrapper=d;this.addEvent("complete",function(){this.open=(d["offset"+this.layout.capitalize()]!=0);if(this.open&&this.options.resetHeight){d.setStyle("height","");
|
}this.now=[];this.open=true;this.wrapper=d;this.addEvent("complete",function(){this.open=(d["offset"+this.layout.capitalize()]!=0);if(this.open&&this.options.resetHeight){d.setStyle("height","");
|
||||||
@ -164,7 +159,7 @@ switch(b){case"in":f=a;break;case"out":f=g;break;case"toggle":f=(c==0)?a:g;}retu
|
|||||||
this.open=true;return this.set([0,this.offset]);},toggle:function(a){return this.start("toggle",a);}});Element.Properties.slide={set:function(a){this.get("slide").cancel().setOptions(a);
|
this.open=true;return this.set([0,this.offset]);},toggle:function(a){return this.start("toggle",a);}});Element.Properties.slide={set:function(a){this.get("slide").cancel().setOptions(a);
|
||||||
return this;},get:function(){var a=this.retrieve("slide");if(!a){a=new Fx.Slide(this,{link:"cancel"});this.store("slide",a);}return a;}};Element.implement({slide:function(d,e){d=d||"toggle";
|
return this;},get:function(){var a=this.retrieve("slide");if(!a){a=new Fx.Slide(this,{link:"cancel"});this.store("slide",a);}return a;}};Element.implement({slide:function(d,e){d=d||"toggle";
|
||||||
var b=this.get("slide"),a;switch(d){case"hide":b.hide(e);break;case"show":b.show(e);break;case"toggle":var c=this.retrieve("slide:flag",b.open);b[c?"slideOut":"slideIn"](e);
|
var b=this.get("slide"),a;switch(d){case"hide":b.hide(e);break;case"show":b.show(e);break;case"toggle":var c=this.retrieve("slide:flag",b.open);b[c?"slideOut":"slideIn"](e);
|
||||||
this.store("slide:flag",!c);a=true;break;default:b.start(d,e);}if(!a){this.eliminate("slide:flag");}return this;}});var SmoothScroll=Fx.SmoothScroll=new Class({Extends:Fx.Scroll,options:{axes:["x","y"]},initialize:function(c,d){d=d||document;
|
this.store("slide:flag",!c);a=true;break;default:b.start(d,e);}if(!a){this.eliminate("slide:flag");}return this;}});Fx.SmoothScroll=new Class({Extends:Fx.Scroll,options:{axes:["x","y"]},initialize:function(c,d){d=d||document;
|
||||||
this.doc=d.getDocument();this.parent(this.doc,c);var e=d.getWindow(),a=e.location.href.match(/^[^#]*/)[0]+"#",b=$$(this.options.links||this.doc.links);
|
this.doc=d.getDocument();this.parent(this.doc,c);var e=d.getWindow(),a=e.location.href.match(/^[^#]*/)[0]+"#",b=$$(this.options.links||this.doc.links);
|
||||||
b.each(function(g){if(g.href.indexOf(a)!=0){return;}var f=g.href.substr(a.length);if(f){this.useLink(g,f);}},this);this.addEvent("complete",function(){e.location.hash=this.anchor;
|
b.each(function(g){if(g.href.indexOf(a)!=0){return;}var f=g.href.substr(a.length);if(f){this.useLink(g,f);}},this);this.addEvent("complete",function(){e.location.hash=this.anchor;
|
||||||
this.element.scrollTo(this.to[0],this.to[1]);},true);},useLink:function(b,a){b.addEvent("click",function(d){var c=document.id(a)||this.doc.getElement("a[name="+a+"]");
|
this.element.scrollTo(this.to[0],this.to[1]);},true);},useLink:function(b,a){b.addEvent("click",function(d){var c=document.id(a)||this.doc.getElement("a[name="+a+"]");
|
||||||
@ -235,14 +230,57 @@ if(g!=0){var e=(j-c)/l;var b=(j-d)/l;var m=(j-k)/l;if(c==j){h=m-b;}else{if(d==j)
|
|||||||
},hsbToRgb:function(){var d=Math.round(this[2]/100*255);if(this[1]==0){return[d,d,d];}else{var b=this[0]%360;var g=b%60;var h=Math.round((this[2]*(100-this[1]))/10000*255);
|
},hsbToRgb:function(){var d=Math.round(this[2]/100*255);if(this[1]==0){return[d,d,d];}else{var b=this[0]%360;var g=b%60;var h=Math.round((this[2]*(100-this[1]))/10000*255);
|
||||||
var e=Math.round((this[2]*(6000-this[1]*g))/600000*255);var c=Math.round((this[2]*(6000-this[1]*(60-g)))/600000*255);switch(Math.floor(b/60)){case 0:return[d,c,h];
|
var e=Math.round((this[2]*(6000-this[1]*g))/600000*255);var c=Math.round((this[2]*(6000-this[1]*(60-g)))/600000*255);switch(Math.floor(b/60)){case 0:return[d,c,h];
|
||||||
case 1:return[e,d,h];case 2:return[h,d,c];case 3:return[h,e,d];case 4:return[c,h,d];case 5:return[d,h,e];}}return false;}});String.implement({rgbToHsb:function(){var b=this.match(/\d{1,3}/g);
|
case 1:return[e,d,h];case 2:return[h,d,c];case 3:return[h,e,d];case 4:return[c,h,d];case 5:return[d,h,e];}}return false;}});String.implement({rgbToHsb:function(){var b=this.match(/\d{1,3}/g);
|
||||||
return(b)?b.rgbToHsb():null;},hsbToRgb:function(){var b=this.match(/\d{1,3}/g);return(b)?b.hsbToRgb():null;}});})();(function(){var b=null,a={},e={};var d=function(g){if(instanceOf(g,f.Set)){return g;
|
return(b)?b.rgbToHsb():null;},hsbToRgb:function(){var b=this.match(/\d{1,3}/g);return(b)?b.hsbToRgb():null;}});})();Events.Pseudos=function(g,c,e){var b="monitorEvents:";
|
||||||
}else{return a[g];}};var f=this.Locale={define:function(g,k,i,j){var h;if(instanceOf(g,f.Set)){h=g.name;if(h){a[h]=g;}}else{h=g;if(!a[h]){a[h]=new f.Set(h);
|
var a=function(h){return{store:h.store?function(i,j){h.store(b+i,j);}:function(i,j){(h.$monitorEvents||(h.$monitorEvents={}))[i]=j;},retrieve:h.retrieve?function(i,j){return h.retrieve(b+i,j);
|
||||||
}g=a[h];}if(k){g.define(k,i,j);}if(k=="cascade"){return f.inherit(h,i);}if(!b){b=g;}return g;},use:function(g){g=d(g);if(g){b=g;this.fireEvent("change",g);
|
}:function(i,j){if(!h.$monitorEvents){return j;}return h.$monitorEvents[i]||j;}};};var f=function(j){if(j.indexOf(":")==-1||!g){return null;}var i=Slick.parse(j).expressions[0][0],m=i.pseudos,h=m.length,k=[];
|
||||||
this.fireEvent("langChange",g.name);}return this;},getCurrent:function(){return b;},get:function(h,g){return(b)?b.get(h,g):"";},inherit:function(g,h,i){g=d(g);
|
while(h--){if(g[m[h].key]){k.push({event:i.tag,value:m[h].value,pseudo:m[h].key,original:j});}}return k.length?k:null;};var d=function(h){return Object.merge.apply(this,h.map(function(i){return g[i.pseudo].options||{};
|
||||||
if(g){g.inherit(h,i);}return this;},list:function(){return Object.keys(a);}};Object.append(f,new Events);f.Set=new Class({sets:{},inherits:{locales:[],sets:{}},initialize:function(g){this.name=g||"";
|
}));};return{addEvent:function(m,p,j){var n=f(m);if(!n){return c.call(this,m,p,j);}var k=a(this),s=k.retrieve(m,[]),h=n[0].event,t=d(n),o=p,i=t[h]||{},l=Array.slice(arguments,2),r=this,q;
|
||||||
},define:function(j,h,i){var g=this.sets[j];if(!g){g={};}if(h){if(typeOf(h)=="object"){g=Object.merge(g,h);}else{g[h]=i;}}this.sets[j]=g;return this;},get:function(s,k,r){var q=Object.getFromPath(this.sets,s);
|
if(i.args){l.append(Array.from(i.args));}if(i.base){h=i.base;}if(i.onAdd){i.onAdd(this);}n.each(function(u){var v=o;o=function(){(i.listener||g[u.pseudo].listener).call(r,u,v,arguments,q,t);
|
||||||
if(q!=null){var n=typeOf(q);if(n=="function"){q=q.apply(null,Array.from(k));}else{if(n=="object"){q=Object.clone(q);}}return q;}var j=s.indexOf("."),p=j<0?s:s.substr(0,j),m=(this.inherits.sets[p]||[]).combine(this.inherits.locales).include("en-US");
|
};});q=o.bind(this);s.include({event:p,monitor:q});k.store(m,s);c.apply(this,[m,p].concat(l));return c.apply(this,[h,q].concat(l));},removeEvent:function(l,n){var m=f(l);
|
||||||
if(!r){r=[];}for(var h=0,g=m.length;h<g;h++){if(r.contains(m[h])){continue;}r.include(m[h]);var o=a[m[h]];if(!o){continue;}q=o.get(s,k,r);if(q!=null){return q;
|
if(!m){return e.call(this,l,n);}var j=a(this),o=j.retrieve(l);if(!o){return this;}var h=m[0].event,p=d(m),i=p[h]||{},k=Array.slice(arguments,2);if(i.args){k.append(Array.from(i.args));
|
||||||
}}return"";},inherit:function(h,i){h=Array.from(h);if(i&&!this.inherits.sets[i]){this.inherits.sets[i]=[];}var g=h.length;while(g--){(i?this.inherits.sets[i]:this.inherits.locales).unshift(h[g]);
|
}if(i.base){h=i.base;}if(i.onRemove){i.onRemove(this);}e.apply(this,[l,n].concat(k));o.each(function(q,r){if(!n||q.event==n){e.apply(this,[h,q.monitor].concat(k));
|
||||||
}return this;}});var c=MooTools.lang={};Object.append(c,f,{setLanguage:f.use,getCurrentLanguage:function(){var g=f.getCurrent();return(g)?g.name:null;},set:function(){f.define.apply(this,arguments);
|
}delete o[r];},this);j.store(l,o);return this;}};};(function(){var b={once:{listener:function(e,f,d,c){f.apply(this,d);this.removeEvent(e.event,c).removeEvent(e.original,f);
|
||||||
return this;},get:function(i,h,g){if(h){i+="."+h;}return f.get(i,g);}});})();
|
}},throttle:{listener:function(d,e,c){if(!e._throttled){e.apply(this,c);e._throttled=setTimeout(function(){e._throttled=false;},d.value||250);}}},pause:{listener:function(d,e,c){clearTimeout(e._pause);
|
||||||
|
e._pause=e.delay(d.value||250,this,c);}}};Events.definePseudo=function(c,d){b[c]=Type.isFunction(d)?{listener:d}:d;return this;};Events.lookupPseudo=function(c){return b[c];
|
||||||
|
};var a=Events.prototype;Events.implement(Events.Pseudos(b,a.addEvent,a.removeEvent));["Request","Fx"].each(function(c){if(this[c]){this[c].implement(Events.prototype);
|
||||||
|
}});})();(function(){var d={},c=["once","throttle","pause"],b=c.length;while(b--){d[c[b]]=Events.lookupPseudo(c[b]);}Event.definePseudo=function(e,f){d[e]=Type.isFunction(f)?{listener:f}:f;
|
||||||
|
return this;};var a=Element.prototype;[Element,Window,Document].invoke("implement",Events.Pseudos(d,a.addEvent,a.removeEvent));})();(function(){var a="$moo:keys-pressed",b="$moo:keys-keyup";
|
||||||
|
Event.definePseudo("keys",function(d,e,c){var g=c[0],f=[],h=this.retrieve(a,[]);f.append(d.value.replace("++",function(){f.push("+");return"";}).split("+"));
|
||||||
|
h.include(g.key);if(f.every(function(j){return h.contains(j);})){e.apply(this,c);}this.store(a,h);if(!this.retrieve(b)){var i=function(j){(function(){h=this.retrieve(a,[]).erase(j.key);
|
||||||
|
this.store(a,h);}).delay(0,this);};this.store(b,i).addEvent("keyup",i);}});Object.append(Event.Keys,{shift:16,control:17,alt:18,capslock:20,pageup:33,pagedown:34,end:35,home:36,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":Browser.firefox?109:189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222,"+":107});
|
||||||
|
})();(function(){var a=this.Keyboard=new Class({Extends:Events,Implements:[Options],options:{defaultEventType:"keydown",active:false,manager:null,events:{},nonParsedEvents:["activate","deactivate","onactivate","ondeactivate","changed","onchanged"]},initialize:function(f){if(f&&f.manager){this._manager=f.manager;
|
||||||
|
delete f.manager;}this.setOptions(f);this._setup();},addEvent:function(h,g,f){return this.parent(a.parse(h,this.options.defaultEventType,this.options.nonParsedEvents),g,f);
|
||||||
|
},removeEvent:function(g,f){return this.parent(a.parse(g,this.options.defaultEventType,this.options.nonParsedEvents),f);},toggleActive:function(){return this[this.isActive()?"deactivate":"activate"]();
|
||||||
|
},activate:function(f){if(f){if(f.isActive()){return this;}if(this._activeKB&&f!=this._activeKB){this.previous=this._activeKB;this.previous.fireEvent("deactivate");
|
||||||
|
}this._activeKB=f.fireEvent("activate");a.manager.fireEvent("changed");}else{if(this._manager){this._manager.activate(this);}}return this;},isActive:function(){return this._manager?(this._manager._activeKB==this):(a.manager==this);
|
||||||
|
},deactivate:function(f){if(f){if(f===this._activeKB){this._activeKB=null;f.fireEvent("deactivate");a.manager.fireEvent("changed");}}else{if(this._manager){this._manager.deactivate(this);
|
||||||
|
}}return this;},relinquish:function(){if(this.isActive()&&this._manager&&this._manager.previous){this._manager.activate(this._manager.previous);}else{this.deactivate();
|
||||||
|
}return this;},manage:function(f){if(f._manager){f._manager.drop(f);}this._instances.push(f);f._manager=this;if(!this._activeKB){this.activate(f);}return this;
|
||||||
|
},drop:function(f){f.relinquish();this._instances.erase(f);if(this._activeKB==f){if(this.previous&&this._instances.contains(this.previous)){this.activate(this.previous);
|
||||||
|
}else{this._activeKB=this._instances[0];}}return this;},trace:function(){a.trace(this);},each:function(f){a.each(this,f);},_instances:[],_disable:function(f){if(this._activeKB==f){this._activeKB=null;
|
||||||
|
}},_setup:function(){this.addEvents(this.options.events);if(a.manager&&!this._manager){a.manager.manage(this);}if(this.options.active){this.activate();
|
||||||
|
}else{this.relinquish();}},_handle:function(h,g){if(h.preventKeyboardPropagation){return;}var f=!!this._manager;if(f&&this._activeKB){this._activeKB._handle(h,g);
|
||||||
|
if(h.preventKeyboardPropagation){return;}}this.fireEvent(g,h);if(!f&&this._activeKB){this._activeKB._handle(h,g);}}});var b={};var c=["shift","control","alt","meta"];
|
||||||
|
var e=/^(?:shift|control|ctrl|alt|meta)$/;a.parse=function(h,g,k){if(k&&k.contains(h.toLowerCase())){return h;}h=h.toLowerCase().replace(/^(keyup|keydown):/,function(m,l){g=l;
|
||||||
|
return"";});if(!b[h]){var f,j={};h.split("+").each(function(l){if(e.test(l)){j[l]=true;}else{f=l;}});j.control=j.control||j.ctrl;var i=[];c.each(function(l){if(j[l]){i.push(l);
|
||||||
|
}});if(f){i.push(f);}b[h]=i.join("+");}return g+":keys("+b[h]+")";};a.each=function(f,g){var h=f||a.manager;while(h){g.run(h);h=h._activeKB;}};a.stop=function(f){f.preventKeyboardPropagation=true;
|
||||||
|
};a.manager=new a({active:true});a.trace=function(f){f=f||a.manager;var g=window.console&&console.log;if(g){console.log("the following items have focus: ");
|
||||||
|
}a.each(f,function(h){if(g){console.log(document.id(h.widget)||h.wiget||h);}});};var d=function(g){var f=[];c.each(function(h){if(g[h]){f.push(h);}});if(!e.test(g.key)){f.push(g.key);
|
||||||
|
}a.manager._handle(g,g.type+":keys("+f.join("+")+")");};document.addEvents({keyup:d,keydown:d});})();Keyboard.prototype.options.nonParsedEvents.combine(["rebound","onrebound"]);
|
||||||
|
Keyboard.implement({addShortcut:function(b,a){this._shortcuts=this._shortcuts||[];this._shortcutIndex=this._shortcutIndex||{};a.getKeyboard=Function.from(this);
|
||||||
|
a.name=b;this._shortcutIndex[b]=a;this._shortcuts.push(a);if(a.keys){this.addEvent(a.keys,a.handler);}return this;},addShortcuts:function(b){for(var a in b){this.addShortcut(a,b[a]);
|
||||||
|
}return this;},removeShortcut:function(b){var a=this.getShortcut(b);if(a&&a.keys){this.removeEvent(a.keys,a.handler);delete this._shortcutIndex[b];this._shortcuts.erase(a);
|
||||||
|
}return this;},removeShortcuts:function(a){a.each(this.removeShortcut,this);return this;},getShortcuts:function(){return this._shortcuts||[];},getShortcut:function(a){return(this._shortcutIndex||{})[a];
|
||||||
|
}});Keyboard.rebind=function(b,a){Array.from(a).each(function(c){c.getKeyboard().removeEvent(c.keys,c.handler);c.getKeyboard().addEvent(b,c.handler);c.keys=b;
|
||||||
|
c.getKeyboard().fireEvent("rebound");});};Keyboard.getActiveShortcuts=function(b){var a=[],c=[];Keyboard.each(b,[].push.bind(a));a.each(function(d){c.extend(d.getShortcuts());
|
||||||
|
});return c;};Keyboard.getShortcut=function(c,b,d){d=d||{};var a=d.many?[]:null,e=d.many?function(g){var f=g.getShortcut(c);if(f){a.push(f);}}:function(f){if(!a){a=f.getShortcut(c);
|
||||||
|
}};Keyboard.each(b,e);return a;};Keyboard.getShortcuts=function(b,a){return Keyboard.getShortcut(b,a,{many:true});};(function(){var b=null,a={},d={};var c=function(f){if(instanceOf(f,e.Set)){return f;
|
||||||
|
}else{return a[f];}};var e=this.Locale={define:function(f,j,h,i){var g;if(instanceOf(f,e.Set)){g=f.name;if(g){a[g]=f;}}else{g=f;if(!a[g]){a[g]=new e.Set(g);
|
||||||
|
}f=a[g];}if(j){f.define(j,h,i);}if(!b){b=f;}return f;},use:function(f){f=c(f);if(f){b=f;this.fireEvent("change",f);}return this;},getCurrent:function(){return b;
|
||||||
|
},get:function(g,f){return(b)?b.get(g,f):"";},inherit:function(f,g,h){f=c(f);if(f){f.inherit(g,h);}return this;},list:function(){return Object.keys(a);
|
||||||
|
}};Object.append(e,new Events);e.Set=new Class({sets:{},inherits:{locales:[],sets:{}},initialize:function(f){this.name=f||"";},define:function(i,g,h){var f=this.sets[i];
|
||||||
|
if(!f){f={};}if(g){if(typeOf(g)=="object"){f=Object.merge(f,g);}else{f[g]=h;}}this.sets[i]=f;return this;},get:function(r,j,q){var p=Object.getFromPath(this.sets,r);
|
||||||
|
if(p!=null){var m=typeOf(p);if(m=="function"){p=p.apply(null,Array.from(j));}else{if(m=="object"){p=Object.clone(p);}}return p;}var h=r.indexOf("."),o=h<0?r:r.substr(0,h),k=(this.inherits.sets[o]||[]).combine(this.inherits.locales).include("en-US");
|
||||||
|
if(!q){q=[];}for(var g=0,f=k.length;g<f;g++){if(q.contains(k[g])){continue;}q.include(k[g]);var n=a[k[g]];if(!n){continue;}p=n.get(r,j,q);if(p!=null){return p;
|
||||||
|
}}return"";},inherit:function(g,h){g=Array.from(g);if(h&&!this.inherits.sets[h]){this.inherits.sets[h]=[];}var f=g.length;while(f--){(h?this.inherits.sets[h]:this.inherits.locales).unshift(g[f]);
|
||||||
|
}return this;}});})();
|
@ -182,12 +182,6 @@ function afterMindpotLibraryLoading() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Events ...
|
|
||||||
$(document).addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
|
|
||||||
$("ffoxWorkarroundInput").addEvent('keydown', designer.keyEventHandler.bindWithEvent(designer));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Save event handler ....
|
// Save event handler ....
|
||||||
var saveButton = $('saveButton');
|
var saveButton = $('saveButton');
|
||||||
saveButton.addEvent('click', function(event) {
|
saveButton.addEvent('click', function(event) {
|
||||||
@ -269,15 +263,14 @@ function afterMindpotLibraryLoading() {
|
|||||||
|
|
||||||
// Autosave ...
|
// Autosave ...
|
||||||
if (!isTryMode) {
|
if (!isTryMode) {
|
||||||
var autosave = function() {
|
(function() {
|
||||||
|
|
||||||
if (designer.needsSave()) {
|
if (designer.needsSave()) {
|
||||||
designer.save(function() {
|
designer.save(function() {
|
||||||
var monitor = core.Monitor.getInstance();
|
var monitor = core.Monitor.getInstance();
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
};
|
}).periodical(30000);
|
||||||
autosave.periodical(30000);
|
|
||||||
|
|
||||||
// To prevent the user from leaving the page with changes ...
|
// To prevent the user from leaving the page with changes ...
|
||||||
window.onbeforeunload = function() {
|
window.onbeforeunload = function() {
|
||||||
@ -290,7 +283,9 @@ function afterMindpotLibraryLoading() {
|
|||||||
var menu = new mindplot.widget.Menu(designer);
|
var menu = new mindplot.widget.Menu(designer);
|
||||||
|
|
||||||
// If a node has focus, focus can be move to another node using the keys.
|
// If a node has focus, focus can be move to another node using the keys.
|
||||||
designer._cleanScreen = function(){menu.clear()};
|
designer._cleanScreen = function() {
|
||||||
|
menu.clear()
|
||||||
|
};
|
||||||
|
|
||||||
// If not problem has occured, I close the dialod ...
|
// If not problem has occured, I close the dialod ...
|
||||||
var closeDialog = function() {
|
var closeDialog = function() {
|
||||||
@ -333,5 +328,6 @@ function buildMindmapDesigner() {
|
|||||||
}.delay(1000)
|
}.delay(1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ function buildMindmapDesigner() {
|
|||||||
// body margin ...
|
// body margin ...
|
||||||
editorProperties.width = screenWidth;
|
editorProperties.width = screenWidth;
|
||||||
editorProperties.height = screenHeight;
|
editorProperties.height = screenHeight;
|
||||||
editorProperties.viewMode = true;
|
editorProperties.readOnly = true;
|
||||||
|
|
||||||
designer = new mindplot.MindmapDesigner(editorProperties, container);
|
designer = new mindplot.MindmapDesigner(editorProperties, container);
|
||||||
designer.loadFromXML(mapId, mapXml);
|
designer.loadFromXML(mapId, mapXml);
|
||||||
|
Loading…
Reference in New Issue
Block a user