mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Replace owr mouse function for a mootool one.
This commit is contained in:
parent
c2521f0f9f
commit
d20e5cf6d5
@ -50,76 +50,6 @@ Math.sign = function(value) {
|
||||
return (value >= 0) ? 1 : -1;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the mouse position.
|
||||
*/
|
||||
core.Utils.getMousePosition = function(event) {
|
||||
var xcoord = -1;
|
||||
var ycoord = -1;
|
||||
|
||||
if (!$defined(event)) {
|
||||
if ($defined(window.event)) {
|
||||
//Internet Explorer
|
||||
event = window.event;
|
||||
} else {
|
||||
//total failure, we have no way of referencing the event
|
||||
throw "Could not obtain mouse position";
|
||||
}
|
||||
}
|
||||
if ($defined(event.$extended)) {
|
||||
event = event.event;
|
||||
}
|
||||
if (typeof( event.pageX ) == 'number') {
|
||||
//most browsers
|
||||
xcoord = event.pageX;
|
||||
ycoord = event.pageY;
|
||||
} else if (typeof( event.clientX ) == 'number') {
|
||||
//Internet Explorer and older browsers
|
||||
//other browsers provide this, but follow the pageX/Y branch
|
||||
xcoord = event.clientX;
|
||||
ycoord = event.clientY;
|
||||
var badOldBrowser = ( window.navigator.userAgent.indexOf('Opera') + 1 ) ||
|
||||
( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ||
|
||||
( navigator.vendor == 'KDE' );
|
||||
if (!badOldBrowser) {
|
||||
if (document.body && ( document.body.scrollLeft || document.body.scrollTop )) {
|
||||
//IE 4, 5 & 6 (in non-standards compliant mode)
|
||||
xcoord += document.body.scrollLeft;
|
||||
ycoord += document.body.scrollTop;
|
||||
} else if (document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop )) {
|
||||
//IE 6 (in standards compliant mode)
|
||||
xcoord += document.documentElement.scrollLeft;
|
||||
ycoord += document.documentElement.scrollTop;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw "Could not obtain mouse position";
|
||||
}
|
||||
|
||||
|
||||
return {x:xcoord,y:ycoord};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Calculate the position of the passed element.
|
||||
*/
|
||||
core.Utils.workOutDivElementPosition = function(divElement) {
|
||||
var curleft = 0;
|
||||
var curtop = 0;
|
||||
if ($defined(divElement.offsetParent)) {
|
||||
curleft = divElement.offsetLeft;
|
||||
curtop = divElement.offsetTop;
|
||||
while (divElement = divElement.offsetParent) {
|
||||
curleft += divElement.offsetLeft;
|
||||
curtop += divElement.offsetTop;
|
||||
}
|
||||
}
|
||||
return {x:curleft,y:curtop};
|
||||
};
|
||||
|
||||
|
||||
core.Utils.innerXML = function(/*Node*/node) {
|
||||
// summary:
|
||||
// Implementation of MS's innerXML function.
|
||||
|
@ -132,6 +132,8 @@ mindplot.MindmapDesigner = new Class({
|
||||
|
||||
setViewPort : function(size) {
|
||||
this._workspace.setViewPort(size);
|
||||
var model = this.getModel();
|
||||
this._workspace.setZoom(model.getZoom(), true);
|
||||
},
|
||||
|
||||
_buildNodeGraph : function(model) {
|
||||
|
@ -34,7 +34,7 @@ mindplot.ScreenManager = new Class({
|
||||
|
||||
setScale : function(scale) {
|
||||
$assert(scale, 'Screen scale can not be null');
|
||||
this._workspaceScale = scale;
|
||||
this._scale = scale;
|
||||
},
|
||||
|
||||
addEvent : function(event, listener) {
|
||||
@ -73,8 +73,8 @@ mindplot.ScreenManager = new Class({
|
||||
y = y - this._offset.y;
|
||||
|
||||
// Scale coordinate in order to be relative to the workspace. That's coord/size;
|
||||
x = x / this._workspaceScale;
|
||||
y = y / this._workspaceScale;
|
||||
x = x / this._scale;
|
||||
y = y / this._scale;
|
||||
|
||||
// Remove decimal part..
|
||||
return {x:x,y:y};
|
||||
@ -113,21 +113,21 @@ mindplot.ScreenManager = new Class({
|
||||
return {x:x + topicPosition.x,y:y + topicPosition.y};
|
||||
},
|
||||
|
||||
getWorkspaceMousePosition : function(e) {
|
||||
getWorkspaceMousePosition : function(event) {
|
||||
// Retrieve current mouse position.
|
||||
var mousePosition = this._getMousePosition(e);
|
||||
var mousePosition = this._getMousePosition(event);
|
||||
var x = mousePosition.x;
|
||||
var y = mousePosition.y;
|
||||
|
||||
// Subtract div position.
|
||||
var containerElem = this.getContainer();
|
||||
var containerPosition = core.Utils.workOutDivElementPosition(containerElem);
|
||||
var containerPosition = this._getDivPosition(containerElem);
|
||||
x = x - containerPosition.x;
|
||||
y = y - containerPosition.y;
|
||||
|
||||
// Scale coordinate in order to be relative to the workspace. That's coordSize/size;
|
||||
x = x * this._workspaceScale;
|
||||
y = y * this._workspaceScale;
|
||||
x = x * this._scale;
|
||||
y = y * this._scale;
|
||||
|
||||
// Add workspace offset.
|
||||
x = x + this._offset.x;
|
||||
@ -138,10 +138,25 @@ mindplot.ScreenManager = new Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* http://www.howtocreate.co.uk/tutorials/javascript/eventinfo
|
||||
* Calculate the position of the passed element.
|
||||
*/
|
||||
_getDivPosition : function(divElement) {
|
||||
var curleft = 0;
|
||||
var curtop = 0;
|
||||
if ($defined(divElement.offsetParent)) {
|
||||
curleft = divElement.offsetLeft;
|
||||
curtop = divElement.offsetTop;
|
||||
while (divElement = divElement.offsetParent) {
|
||||
curleft += divElement.offsetLeft;
|
||||
curtop += divElement.offsetTop;
|
||||
}
|
||||
}
|
||||
return {x:curleft,y:curtop};
|
||||
},
|
||||
|
||||
_getMousePosition : function(event) {
|
||||
return core.Utils.getMousePosition(event);
|
||||
$assert(event, 'event can not be null');
|
||||
return {x:event.client.x,y:event.client.y};
|
||||
},
|
||||
|
||||
getContainer : function() {
|
||||
|
@ -219,7 +219,6 @@ mindplot.Workspace = new Class({
|
||||
|
||||
setViewPort : function(size) {
|
||||
this._viewPort = size;
|
||||
this.setZoom(this._zoom, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user