var mod_dagMapSize_offset = 15; var mod_dagMapSize_active = false; mb_registerInitFunctions("mod_dragMapSize_init()"); mb_registerSubFunctions("mod_dragMapSize_arrange()"); function mod_dragMapSize_arrange(){ var left = parseInt(document.getElementById(mod_dragMapSize_target).style.left) + parseInt(document.getElementById(mod_dragMapSize_target).style.width) + mod_dagMapSize_offset - (parseInt(document.getElementById('dragMapSize').style.width)/2); var top = parseInt(document.getElementById(mod_dragMapSize_target).style.top) + parseInt(document.getElementById(mod_dragMapSize_target).style.height) + mod_dagMapSize_offset - (parseInt(document.getElementById('dragMapSize').style.height)/2); mb_arrangeElement('','dragMapSize' , left, top); } function mod_dragMapSize_init(){ var el = document.getElementById("dragMapSize"); el.onmousedown = mod_dragMapSize_down; mod_dragMapSize_arrange(); } function mod_dragMapSize_down(e){ 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_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($.browser.msie) mouseCatcher.style.background = "url(../img/transparent.gif)"; mouseCatcher.style.left=clickX-250; mouseCatcher.style.top=clickY-250; return false; } } 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; mb_end_y = clickY; 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); document.getElementById(mod_dragMapSize_target).style.width = mb_mapObj[ind].width; document.getElementById(mod_dragMapSize_target).style.height = mb_mapObj[ind].height; window.frames[mod_dragMapSize_target].document.getElementById("maps").style.width = mb_mapObj[ind].width; window.frames[mod_dragMapSize_target].document.getElementById("maps").style.height = mb_mapObj[ind].height; var mybbox = mb_mapObj[ind].extent.split(","); mb_mapObj[ind].extent = mybbox[0] + "," + pos[1] + "," + pos[0] + "," + mybbox[3]; setMapRequest(mod_dragMapSize_target); eventResizeMap.trigger(); } function mod_dragMapSize_drag(e){ if(mod_dagMapSize_active){ if (!e) e = window.event; mb_getMousePos(e); 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); } }