mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Remove layout harcodes.
This commit is contained in:
parent
306133cd5e
commit
00ca42f7fe
@ -107,7 +107,6 @@
|
|||||||
<filelist dir="${basedir}/src/main/javascript/" files="LocalStorageManager.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="LocalStorageManager.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="EditorProperties.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="EditorProperties.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="IconGroup.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="IconGroup.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="BubbleTip.js"/>
|
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="Icon.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="Icon.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="LinkIcon.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="LinkIcon.js"/>
|
||||||
<filelist dir="${basedir}/src/main/javascript/" files="NoteIcon.js"/>
|
<filelist dir="${basedir}/src/main/javascript/" files="NoteIcon.js"/>
|
||||||
|
@ -1,159 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.BubbleTip = new Class({
|
|
||||||
initialize : function(divContainer) {
|
|
||||||
this.options = {
|
|
||||||
panel:null,
|
|
||||||
container:null,
|
|
||||||
divContainer:divContainer,
|
|
||||||
content:null,
|
|
||||||
onShowComplete:Class.empty,
|
|
||||||
onHideComplete:Class.empty,
|
|
||||||
width:null,
|
|
||||||
height:null,
|
|
||||||
form:null
|
|
||||||
};
|
|
||||||
if ($defined(this.options.form))
|
|
||||||
this.scanElements(this.options.form);
|
|
||||||
this.buildBubble();
|
|
||||||
this._isMouseOver = false;
|
|
||||||
this._open = false;
|
|
||||||
},
|
|
||||||
scanElements : function(form) {
|
|
||||||
$$($(form).getElements('a')).each(function(el) {
|
|
||||||
if (el.href && el.hasClass('bubble') && !el.onclick) {
|
|
||||||
el.addEvent('mouseover', this.click.bindWithEvent(this, el));
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
},
|
|
||||||
buildBubble : function() {
|
|
||||||
var opts = this.options;
|
|
||||||
|
|
||||||
var panel = new Element('div').addClass('bubbleContainer');
|
|
||||||
if ($defined(opts.height))
|
|
||||||
panel.setStyle('height', opts.height);
|
|
||||||
if ($defined(opts.width))
|
|
||||||
panel.setStyle('width', opts.width);
|
|
||||||
|
|
||||||
this.center = new Element('div').addClass('bubblePart').addClass('bubbleCenterBlue');
|
|
||||||
this.center.inject(panel);
|
|
||||||
if (!$defined(opts.divContainer)) {
|
|
||||||
opts.divContainer = document.body;
|
|
||||||
}
|
|
||||||
panel.injectTop(opts.divContainer);
|
|
||||||
opts.panel = $(panel);
|
|
||||||
opts.panel.setStyle('opacity', 0);
|
|
||||||
opts.panel.addEvent('mouseover', function() {
|
|
||||||
this._isMouseOver = true;
|
|
||||||
}.bind(this));
|
|
||||||
opts.panel.addEvent('mouseleave', function(event) {
|
|
||||||
this.close(event);
|
|
||||||
}.bindWithEvent(this));//this.close.bindWithEvent(this)
|
|
||||||
|
|
||||||
},
|
|
||||||
click : function(event, el) {
|
|
||||||
return this.open(event, el);
|
|
||||||
},
|
|
||||||
open : function(event, content, source) {
|
|
||||||
this._isMouseOver = true;
|
|
||||||
this._evt = new Event(event);
|
|
||||||
this.doOpen.delay(500, this, [content,source]);
|
|
||||||
},
|
|
||||||
doOpen : function(content, source) {
|
|
||||||
if ($defined(this._isMouseOver) && !$defined(this._open) && !$defined(this._opening)) {
|
|
||||||
this._opening = true;
|
|
||||||
var container = new Element('div');
|
|
||||||
$(content).inject(container);
|
|
||||||
this.options.content = content;
|
|
||||||
this.options.container = container;
|
|
||||||
$(this.options.container).inject(this.center);
|
|
||||||
this.init(this._evt, source);
|
|
||||||
$(this.options.panel).effect('opacity', {duration:500, onComplete:function() {
|
|
||||||
this._open = true;
|
|
||||||
this._opening = false;
|
|
||||||
}.bind(this)}).start(0, 100);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateBranchPosition : function(event) {
|
|
||||||
this._evt = new Event(event);
|
|
||||||
},
|
|
||||||
close : function(event) {
|
|
||||||
this._isMouseOver = false;
|
|
||||||
this.doClose.delay(50, this, new Event(event));
|
|
||||||
},
|
|
||||||
doClose : function(event) {
|
|
||||||
|
|
||||||
if (!$defined(this._isMouseOver) && $defined(this._opening))
|
|
||||||
this.doClose.delay(500, this, this._evt);
|
|
||||||
|
|
||||||
if (!$defined(this._isMouseOver) && $defined(this._open)) {
|
|
||||||
this.forceClose();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
forceClose : function() {
|
|
||||||
this.options.panel.effect('opacity', {duration:100, onComplete:function() {
|
|
||||||
this._open = false;
|
|
||||||
$(this.options.panel).setStyles({left:0,top:0});
|
|
||||||
$(this.options.container).remove();
|
|
||||||
}.bind(this)}).start(100, 0);
|
|
||||||
},
|
|
||||||
init : function(event, source) {
|
|
||||||
var opts = this.options;
|
|
||||||
var coordinates = $(opts.panel).getCoordinates();
|
|
||||||
var panelHeight = coordinates.height; //not total height, but close enough
|
|
||||||
var panelWidth = coordinates.width; //not total height, but close enough
|
|
||||||
|
|
||||||
var offset = designer.getWorkSpace().getScreenManager().getWorkspaceIconPosition(source);
|
|
||||||
|
|
||||||
var containerCoords = $(opts.divContainer).getCoordinates();
|
|
||||||
var screenWidth = containerCoords.width;
|
|
||||||
var screenHeight = containerCoords.height;
|
|
||||||
|
|
||||||
var width = $(this.center).getCoordinates().width;
|
|
||||||
|
|
||||||
var invert = !(offset.y > panelHeight); //hint goes on the bottom
|
|
||||||
var invertX = (screenWidth - offset.x > panelWidth); // hint goes on the right
|
|
||||||
$(this.options.panel).remove();
|
|
||||||
this.buildBubble();
|
|
||||||
$(this.options.container).inject(this.center);
|
|
||||||
|
|
||||||
var height = $(this.center).getCoordinates().height;
|
|
||||||
$(opts.panel).setStyles({width:width,height:height});
|
|
||||||
this.moveTopic(offset, $(opts.panel).getCoordinates().height, $(opts.panel).getCoordinates().width, invert, invertX);
|
|
||||||
},
|
|
||||||
moveTopic : function(offset, panelHeight, panelWidth, invert, invertX) {
|
|
||||||
var f = 1, fX = 1;
|
|
||||||
if ($defined(invert))
|
|
||||||
f = 0;
|
|
||||||
if ($defined(invertX))
|
|
||||||
fX = 0;
|
|
||||||
var opts = this.options;
|
|
||||||
$(opts.panel).setStyles({left:offset.x - (panelWidth * fX), top:offset.y - (panelHeight * f)});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
mindplot.BubbleTip.getInstance = function(divContainer) {
|
|
||||||
var result = mindplot.BubbleTip.instance;
|
|
||||||
if (!$defined(result)) {
|
|
||||||
mindplot.BubbleTip.instance = new mindplot.BubbleTip(divContainer);
|
|
||||||
result = mindplot.BubbleTip.instance;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
@ -41,22 +41,17 @@ mindplot.Designer = new Class({
|
|||||||
// Init Screen manager..
|
// Init Screen manager..
|
||||||
var screenManager = new mindplot.ScreenManager(divElement);
|
var screenManager = new mindplot.ScreenManager(divElement);
|
||||||
this._workspace = new mindplot.Workspace(screenManager, this._model.getZoom());
|
this._workspace = new mindplot.Workspace(screenManager, this._model.getZoom());
|
||||||
this._readOnly = profile.readOnly ? true : false;
|
|
||||||
|
// Init layout manager ...
|
||||||
|
this._eventBussDispatcher = new mindplot.layout.EventBusDispatcher(this.getModel());
|
||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
if (!profile.readOnly) {
|
if (!profile.readOnly) {
|
||||||
this._registerEvents();
|
this._registerEvents();
|
||||||
|
this._dragManager = this._buildDragManager(this._workspace);
|
||||||
// Init drag related classes ...
|
|
||||||
this._dragConnector = new mindplot.DragConnector(this.getModel(), this._workspace);
|
|
||||||
this._dragger = this._buildDragManager(this._workspace);
|
|
||||||
mindplot.DragTopic.init(this._workspace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._relPivot = new mindplot.RelationshipPivot(this._workspace, this);
|
this._relPivot = new mindplot.RelationshipPivot(this._workspace, this);
|
||||||
|
|
||||||
// Init layout manager ...
|
|
||||||
this._eventBussDispatcher = new mindplot.layout.EventBusDispatcher(this.getModel());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_registerEvents : function() {
|
_registerEvents : function() {
|
||||||
@ -115,20 +110,20 @@ mindplot.Designer = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_buildDragManager: function(workspace) {
|
_buildDragManager: function(workspace) {
|
||||||
// Init dragger manager.
|
|
||||||
var dragger = new mindplot.DragManager(workspace);
|
|
||||||
var topics = this.getModel().getTopics();
|
|
||||||
|
|
||||||
var dragConnector = this._dragConnector;
|
var designerModel = this.getModel();
|
||||||
|
var dragConnector = new mindplot.DragConnector(designerModel, this._workspace);
|
||||||
|
var dragManager = new mindplot.DragManager(workspace, this._eventBussDispatcher);
|
||||||
|
var topics = designerModel.getTopics();
|
||||||
|
|
||||||
dragger.addEvent('startdragging', function(event, node) {
|
dragManager.addEvent('startdragging', function() {
|
||||||
// Enable all mouse events.
|
// Enable all mouse events.
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < topics.length; i++) {
|
||||||
topics[i].setMouseEventsEnabled(false);
|
topics[i].setMouseEventsEnabled(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dragger.addEvent('dragging', function(event, dragTopic) {
|
dragManager.addEvent('dragging', function(event, dragTopic) {
|
||||||
dragTopic.updateFreeLayout(event);
|
dragTopic.updateFreeLayout(event);
|
||||||
if (!dragTopic.isFreeLayoutOn(event)) {
|
if (!dragTopic.isFreeLayoutOn(event)) {
|
||||||
// The node is being drag. Is the connection still valid ?
|
// The node is being drag. Is the connection still valid ?
|
||||||
@ -140,14 +135,14 @@ mindplot.Designer = new Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dragger.addEvent('enddragging', function(event, dragTopic) {
|
dragManager.addEvent('enddragging', function(event, dragTopic) {
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < topics.length; i++) {
|
||||||
topics[i].setMouseEventsEnabled(true);
|
topics[i].setMouseEventsEnabled(true);
|
||||||
}
|
}
|
||||||
dragTopic.applyChanges(workspace);
|
dragTopic.applyChanges(workspace);
|
||||||
});
|
});
|
||||||
|
|
||||||
return dragger;
|
return dragManager;
|
||||||
},
|
},
|
||||||
|
|
||||||
setViewPort : function(size) {
|
setViewPort : function(size) {
|
||||||
@ -176,7 +171,7 @@ mindplot.Designer = new Class({
|
|||||||
if (topic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (topic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
|
|
||||||
// Central Topic doesn't support to be dragged
|
// Central Topic doesn't support to be dragged
|
||||||
var dragger = this._dragger;
|
var dragger = this._dragManager;
|
||||||
dragger.add(topic);
|
dragger.add(topic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.DragManager = new Class({
|
mindplot.DragManager = new Class({
|
||||||
initialize:function(workspace) {
|
initialize:function(workspace, eventDispatcher) {
|
||||||
this._workspace = workspace;
|
this._workspace = workspace;
|
||||||
|
this._designerModel = workspace;
|
||||||
this._listeners = {};
|
this._listeners = {};
|
||||||
this._isDragInProcess = false;
|
this._isDragInProcess = false;
|
||||||
|
this._eventDispatcher = eventDispatcher;
|
||||||
|
mindplot.DragTopic.init(this._workspace);
|
||||||
},
|
},
|
||||||
|
|
||||||
add : function(node) {
|
add : function(node) {
|
||||||
@ -35,7 +38,8 @@ mindplot.DragManager = new Class({
|
|||||||
workspace.enableWorkspaceEvents(false);
|
workspace.enableWorkspaceEvents(false);
|
||||||
|
|
||||||
// Set initial position.
|
// Set initial position.
|
||||||
var dragNode = node.createDragNode();
|
var layoutManager = this._eventDispatcher.getLayoutManager();
|
||||||
|
var dragNode = node.createDragNode(layoutManager);
|
||||||
|
|
||||||
// Register mouse move listener ...
|
// Register mouse move listener ...
|
||||||
var mouseMoveListener = dragManager._buildMouseMoveListener(workspace, dragNode, dragManager);
|
var mouseMoveListener = dragManager._buildMouseMoveListener(workspace, dragNode, dragManager);
|
||||||
|
@ -17,13 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.DragTopic = new Class({
|
mindplot.DragTopic = new Class({
|
||||||
initialize:function(dragShape, draggedNode) {
|
initialize:function(dragShape, draggedNode, layoutManger) {
|
||||||
$assert(dragShape, 'Rect can not be null.');
|
$assert(dragShape, 'Rect can not be null.');
|
||||||
$assert(draggedNode, 'draggedNode can not be null.');
|
$assert(draggedNode, 'draggedNode can not be null.');
|
||||||
|
$assert(layoutManger, 'layoutManger can not be null.');
|
||||||
|
|
||||||
this._elem2d = dragShape;
|
this._elem2d = dragShape;
|
||||||
this._order = null;
|
this._order = null;
|
||||||
this._draggedNode = draggedNode;
|
this._draggedNode = draggedNode;
|
||||||
|
this._layoutManager = layoutManger;
|
||||||
this._position = new core.Point();
|
this._position = new core.Point();
|
||||||
this._isInWorkspace = false;
|
this._isInWorkspace = false;
|
||||||
this._isFreeLayoutEnabled = false;
|
this._isFreeLayoutEnabled = false;
|
||||||
@ -37,7 +39,7 @@ mindplot.DragTopic = new Class({
|
|||||||
// Update drag shadow position ....
|
// Update drag shadow position ....
|
||||||
var position = {x:x,y:y};
|
var position = {x:x,y:y};
|
||||||
if (this.isFreeLayoutOn() && this.isConnected()) {
|
if (this.isFreeLayoutOn() && this.isConnected()) {
|
||||||
var _layoutManager = designer._eventBussDispatcher._layoutManager;
|
var _layoutManager = this._layoutManager;
|
||||||
var par = this.getConnectedToTopic();
|
var par = this.getConnectedToTopic();
|
||||||
position = _layoutManager.predict(par.getId(), position, true).position;
|
position = _layoutManager.predict(par.getId(), position, true).position;
|
||||||
}
|
}
|
||||||
@ -54,7 +56,7 @@ mindplot.DragTopic = new Class({
|
|||||||
// In case is not free, pivot must be draw ...
|
// In case is not free, pivot must be draw ...
|
||||||
if (this.isConnected() && !this.isFreeLayoutOn()) {
|
if (this.isConnected() && !this.isFreeLayoutOn()) {
|
||||||
var parent = this.getConnectedToTopic();
|
var parent = this.getConnectedToTopic();
|
||||||
var predict = designer._eventBussDispatcher._layoutManager.predict(parent.getId(), this.getPosition());
|
var predict = this._layoutManager.predict(parent.getId(), this.getPosition());
|
||||||
if (this._order != predict.order) {
|
if (this._order != predict.order) {
|
||||||
var dragPivot = this._getDragPivot();
|
var dragPivot = this._getDragPivot();
|
||||||
var pivotPosition = predict.position;
|
var pivotPosition = predict.position;
|
||||||
|
@ -127,9 +127,9 @@ mindplot.NodeGraph = new Class({
|
|||||||
workspace.removeChild(this);
|
workspace.removeChild(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
createDragNode : function() {
|
createDragNode : function(layoutManager) {
|
||||||
var dragShape = this._buildDragShape();
|
var dragShape = this._buildDragShape();
|
||||||
return new mindplot.DragTopic(dragShape, this);
|
return new mindplot.DragTopic(dragShape, this, layoutManager);
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildDragShape : function() {
|
_buildDragShape : function() {
|
||||||
|
@ -1157,8 +1157,8 @@ mindplot.Topic = new Class({
|
|||||||
return this._isInWorkspace;
|
return this._isInWorkspace;
|
||||||
},
|
},
|
||||||
|
|
||||||
createDragNode : function() {
|
createDragNode : function(layoutManager) {
|
||||||
var result = this.parent();
|
var result = this.parent(layoutManager);
|
||||||
|
|
||||||
// Is the node already connected ?
|
// Is the node already connected ?
|
||||||
var targetTopic = this.getOutgoingConnectedTopic();
|
var targetTopic = this.getOutgoingConnectedTopic();
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</topic>
|
</topic>
|
||||||
</topic>
|
</topic>
|
||||||
<topic position="-336,-100" order="3" text="Web 2.0 Tool" id="22" fontStyle=";;#0c1d6b;;;" bgColor="#add1f7">
|
<topic position="-336,-100" order="3" text="Web 2.0 Tool" id="22" fontStyle=";;#0c1d6b;;;" bgColor="#add1f7">
|
||||||
<topic position="-433,-145" order="0" text="Colaborated" id="23"/>
|
<topic position="-433,-145" order="0" text="Collaborate" id="23"/>
|
||||||
<topic position="-453,-121" order="1" text="No plugin required" id="24">
|
<topic position="-453,-121" order="1" text="No plugin required" id="24">
|
||||||
<icon id="conn_disconnect"/>
|
<icon id="conn_disconnect"/>
|
||||||
</topic>
|
</topic>
|
||||||
|
Loading…
Reference in New Issue
Block a user