[Mapbender-commits] r1013 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Jan 17 10:56:40 EST 2007
Author: nimix
Date: 2007-01-17 10:56:40 -0500 (Wed, 17 Jan 2007)
New Revision: 1013
Modified:
trunk/mapbender/http/javascripts/mod_dragMapSize.php
Log:
drag over other iframes and check for negative size
Modified: trunk/mapbender/http/javascripts/mod_dragMapSize.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_dragMapSize.php 2007-01-16 13:02:50 UTC (rev 1012)
+++ trunk/mapbender/http/javascripts/mod_dragMapSize.php 2007-01-17 15:56:40 UTC (rev 1013)
@@ -57,12 +57,28 @@
if(mod_dagMapSize_active == false){
document.onmouseup = mod_dragMapSize_up;
document.onmousemove = mod_dragMapSize_drag;
+
mb_getMousePos(e);
- mb_start_x=clickX;
- mb_start_y=clickY;
+ mb_start_x = clickX;
+ mb_start_y = clickY;
mb_end_x = clickX;
mb_end_y = clickY;
mod_dagMapSize_active = true;
+
+ //create a div that catches all mouse interactions
+ var dragElement = document.getElementById("dragMapSize");
+ var mouseCatcher = dragElement.parentNode.appendChild(document.createElement('div'));
+ mouseCatcher.setAttribute("id", "dragMapSize_helper");
+ mouseCatcher.style.position = "absolute";
+ mouseCatcher.style.cursor = "move";
+ mouseCatcher.style.width = 500;
+ mouseCatcher.style.height = 500;
+ mouseCatcher.style.zIndex = 160;
+ if(top.ie)
+ mouseCatcher.style.background = "url(/../img/tranparent.gif)";
+ mouseCatcher.style.left=clickX-250;
+ mouseCatcher.style.top=clickY-250;
+
return false;
}
}
@@ -70,6 +86,10 @@
function mod_dragMapSize_up(e){
document.onmouseup = null;
document.onmousemove = null;
+
+ var mouseCatcher = document.getElementById("dragMapSize_helper");
+ mouseCatcher.parentNode.removeChild(mouseCatcher);
+
mod_dagMapSize_active = false;
mb_getMousePos(e);
mb_end_x = clickX;
@@ -77,6 +97,16 @@
var ind = getMapObjIndexByName(mod_dragMapSize_target);
var dif_x = (parseFloat(mb_end_x) - parseFloat(mb_start_x));
var dif_y = (parseFloat(mb_end_y) - parseFloat(mb_start_y));
+
+ if(parseFloat(mb_mapObj[ind].width) + parseFloat(dif_x)<0 ||
+ parseFloat(mb_mapObj[ind].height) + parseFloat(dif_y)<0)
+ {
+ var dif_x = mb_start_x - (parseInt(document.getElementById('dragMapSize').style.width) / 2);
+ var dif_y = mb_start_y - (parseInt(document.getElementById('dragMapSize').style.height) / 2);
+ mb_arrangeElement('', "dragMapSize", dif_x, dif_y);
+ return;
+ }
+
var pos = makeClickPos2RealWorldPos(mod_dragMapSize_target, (parseFloat(mb_mapObj[ind].width) + parseFloat(dif_x)), (parseFloat(mb_mapObj[ind].height) + parseFloat(dif_y)));
mb_mapObj[ind].width = parseFloat(mb_mapObj[ind].width) + parseFloat(dif_x);
mb_mapObj[ind].height = parseFloat(mb_mapObj[ind].height) + parseFloat(dif_y);
@@ -91,11 +121,12 @@
function mod_dragMapSize_drag(e){
if(mod_dagMapSize_active){
+ if (!e)
+ e = window.event;
mb_getMousePos(e);
- mb_end_x = clickX;
- mb_end_y = clickY;
- var dif_x = mb_start_x + (mb_end_x - mb_start_x) - (parseInt(document.getElementById('dragMapSize').style.width)/2);
- var dif_y = mb_start_y + (mb_end_y - mb_start_y) - (parseInt(document.getElementById('dragMapSize').style.height)/2);
+ var dif_x = clickX - (parseInt(document.getElementById('dragMapSize').style.width)/2);
+ var dif_y = clickY - (parseInt(document.getElementById('dragMapSize').style.height)/2);
mb_arrangeElement('', "dragMapSize", dif_x, dif_y);
+ mb_arrangeElement('', "dragMapSize_helper", clickX-250, clickY-250);
}
-}
\ No newline at end of file
+}
More information about the Mapbender_commits
mailing list