CodeChargenewbie
Posts: 114
|
| Posted: 07/31/2008, 6:34 AM |
|
I know YES will be releasing a fix sometime in the future that allows you to move around the modal window. But there must be some way to move around the modal window by editing the javascript codecharge creates, no? It'd be nice to have a moveable modal window right now and who knows when a new update will be released. I will try figuring out a way now, but I'm hoping others have figured out the answer beforehand; hence, the inclusion of this thread.
Thank you very much.
|
 |
 |
CodeChargenewbie
Posts: 114
|
| Posted: 07/31/2008, 12:31 PM |
|
OK, I got it to work. It's not perfect but it's good enough.
|
 |
 |
datadoit
|
| Posted: 07/31/2008, 12:53 PM |
|
Forums are two-way streets. Please share.
|
|
|
 |
CodeChargenewbie
Posts: 114
|
| Posted: 07/31/2008, 1:19 PM |
|
I'm sure they, meaning codecharge, will add it in and my thing won't work anymore. It's not really my thing, I just researched it. Basically, I created all the stuff I needed for javascript and put it in a javascript file. I linked it at the end of the body tag, b/c I was having issues linking it in the header. Afterwards, all you do is call a function called makeDraggable, with its paramter as the ID of the object that you wish to move; in this case, the id of the modal window. The javascript file is here:
Quote :
var dragObject = null;
var mouseOffset = null;
function makeDraggable(item){
if(!item) return;
item.onmousedown = function(ev){
dragObject = this;
mouseOffset = getMouseOffset(this, ev);
return false;
}
}
function getMouseOffset(target, ev){
ev = ev || window.event;
var docPos = getPosition(target);
var mousePos = mouseCoords(ev);
return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}
function getPosition(e){
var left = 0;
var top = 0;
while (e.offsetParent){
left += e.offsetLeft;
top += e.offsetTop;
e = e.offsetParent;
}
left += e.offsetLeft;
top += e.offsetTop;
return {x:left, y:top};
}
function mouseUp(ev)
{
dragObject = null;
}
function mouseMove(ev){
ev = ev || window.event;
var mousePos = mouseCoords(ev);
if(dragObject){
dragObject.style.position = 'absolute';
dragObject.style.top = mousePos.y - mouseOffset.y - 100;
dragObject.style.left = mousePos.x - mouseOffset.x;
return false;
}
}
function mouseCoords(ev)
{
if(ev.pageX || ev.pageY)
{
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
document.onmouseup = mouseUp;
document.onmousemove = mouseMove;
|
 |
 |
datadoit
|
| Posted: 07/31/2008, 4:13 PM |
|
Good stuff!
|
|
|
 |
ckroon
Posts: 869
|
| Posted: 07/31/2008, 7:14 PM |
|
I wonder if that will work with the thickbox modals? I have implemented those with pretty good results.
_________________
Walter Kempees...you are dearly missed. |
 |
 |
|