Forum Moderators: open
var drag = new function() {this.drag = 0;}
document.onmousedown=function(e) {drag.drag = 1; move(e);};
document.onmousemove=function(e) {if (drag.drag==1) {move(e);}};
document.onmouseup=function() {drag.drag = 0; document.getElementById('##########textarea_element_id_goes_here').value='0';};
function move(e)
{
if (!e) {e = window.event;}//IE6
if (e.target) {var t = e.target; var ie = false;}
else if (e.srcElement) {var t = e.srcElement; var ie = true;}
if (t.className.substr(0,4)=='drag')
{
var dragged = document.getElementById(t.className.substr(5));
if (!ie)
{
var l3 = parseInt(window.getComputedStyle(dragged,null).getPropertyValue('left'));
var t3 = parseInt(window.getComputedStyle(dragged,null).getPropertyValue('top'))
}
else
{
var l3 = dragged.currentStyle.left;
var t3 = dragged.currentStyle.top;
}
//Textarea below used as a status to visually determine what is happening.
document.getElementById('##########textarea_element_id_goes_here').value=e.clientX+'\n'+e.clientY+'\n'+l3+'\n'+t3;
var re = false;
}
else {re = true;}
return re;
}
var drag = new function() {this.drag = 0;}
var drag = {drag: 0};
if (e.target) {var t = e.target; var ie = false;}
else if (e.srcElement) {var t = e.srcElement; var ie = true;}
var ie, t;
if (e.target) {t = e.target; ie = false;}
else if (e.srcElement) {t = e.srcElement; ie = true;}
if (t.nodeType == 3) { // Safari text node bug
t = t.parentNode;
}
if (t.className.substr(0,4)=='drag')
if (t.className.substr(0,5)=='drag ')
var dragged = document.getElementById(t.className.substr(5));
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div {
background: #ccc;
border: 1px solid #000;
}
#myForm {
float: left;
width: 250px;
}
</style>
<title>Drag Drop Test</title>
</head>
<body>
<form action="">
<div id="myForm">
<textarea id="logging" rows="3000" cols="24"></textarea>
</div>
</form>
<div class="drag foo" id="foo">Foo</div>
<div class="drag bar" id="bar">Bar</div>
<script type="text/javascript">
var d = document,
drag = {drag: 0},
logging = d.getElementById('logging');
d.onmousedown=function(e) {drag.drag = 1; move(e);};
d.onmousemove=function(e) {if (drag.drag == 1) {move(e);}};
d.onmouseup=function() {drag.drag = 0; logging.value += '0\n';};
function move(e) {
var dragged,
ie,
t,
l3,
t3,
re = true;
if (!e) {e = window.event;}//IE6
if (e.target) {t = e.target; ie = false;}
else if (e.srcElement) {t = e.srcElement; ie = true;}
if (t.className.substr(0,5)=='drag ') {
dragged = document.getElementById(t.className.substr(5));
if (!ie) {
l3 = dragged.offsetLeft;
t3 = dragged.offsetTop;
}
else {
l3 = dragged.currentStyle.left;
t3 = dragged.currentStyle.top;
}
//Textarea below used as a status to visually determine what is happening.
logging.value += 'mouse[x,y]=[' +e.clientX+','+e.clientY+']\nelement[x,y]=['+l3+','+t3+']\n';
re = false;
}
return re;
}
</script>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DHTML</title>
<script type="text/javascript">
//<![CDATA[
var drag = {drag: 0};
document.onmousedown=function(e) {drag.drag = 1; move(e,1);};
document.onmousemove=function(e) {if (drag.drag==1) {move(e,0);}};
document.onmouseup=function() {drag.drag = 0; /*document.getElementById('status').value='0';*/};
var cur_x_init = 0;
var cur_y_init = 0;
var dragged_x_init = 0;
var dragged_y_init = 0;
var dragged_x = 0;
var dragged_y = 0;
var init_dif_x = 0;
var init_dif_y = 0;
function move(e,init)
{
if (!e) {e = window.event;}//IE6 OR: if (document.all) {e = window.event;}//IE6
if (e.target) {var t = e.target; var ie = false;}
else if (e.srcElement) {var t = e.srcElement; var ie = true;}
if (t.className.substr(0,5)=='drag ')
{
var dragged = document.getElementById(t.className.substr(5));
if (init==1)
{
cur_x_init = e.clientX;
cur_y_init = e.clientY;
dragged_x_init = dragged.offsetLeft;
dragged_y_init = dragged.offsetTop;
}
else
{
dragged_x = dragged.offsetLeft;
dragged_y = dragged.offsetTop;
var l = e.clientX - cur_x_init;
var t = e.clientY - cur_y_init;
dragged.style.left = dragged_x_init + l+'px';
//dragged.style.top = dragged_y_init + t+'px';
}
//var xpos = e.clientX-init_dif_x;
document.getElementById('status').value='Init: '+init+'\nCur Init X: '+
cur_x_init+'\nCur Init Y: '+cur_y_init+'\nCur X: '+e.clientX+'\nCur Y: '+
e.clientY+'\nDragged Init X: '+dragged_x_init+'\nDragged Init Y: '+
dragged_y_init+'\nDragged Left: '+dragged_x+'\nDragged Top: '+
dragged_y+'\n'+init_dif_x+'\n'+init_dif_y+'\nxpos = '+xpos;
var re = false;
}
else {re = true;}
return re;
}
//]]>
</script>
<style type="text/css">
#prompts {background: #ccc; border: solid 1px; border-color: #ccc #aaa #aaa #ccc;
height: 398px; left: 50%; margin-top: -198px; margin-left: -369px; position: absolute;
top: 50%; width: 738px; z-index: 3;}
#prompts h2 {background-color: #ddd; height: 20px; line-height: 20px; margin: 0px; text-align: center;}
#prompts h2 span {display: block; text-align: center; width: 738px;}
#prompts textarea {height: 373px; width: 734px;}
</style>
</head>
<body>
<div id="prompts">
<h2><span class="drag prompts">Title - This is the Drag Handle</span></h2>
<textarea id="status"></textarea>
</div>
</body>
</html>
[edited by: Fotiman at 1:45 pm (utc) on Sep 3, 2010]
[edit reason] Breaking up long lines [/edit]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DHTML</title>
<script type="text/javascript">
//<![CDATA[
var drag = {drag: 0};
document.onmousedown=function(e) {drag.drag = 1; move(e,1);};
document.onmousemove=function(e) {if (drag.drag==1) {move(e,0);}};
document.onmouseup=function() {drag.drag = 0; /*document.getElementById('status').value='0';*/};
var cur_x_init = 0;
var cur_y_init = 0;
var cur_x_dif = 0;
var cur_y_dif = 0;
var dragged_x_init = 0;
var dragged_y_init = 0;
var dragged_x = 0;
var dragged_y = 0;
var init_dif_x = 0;
var init_dif_y = 0;
function move(e,init)
{
if (!e) {e = window.event;}//IE6 OR: if (document.all) {e = window.event;}//IE6
if (e.target) {var t = e.target; var ie = false;}
else if (e.srcElement) {var t = e.srcElement; var ie = true;}
if (t.className.substr(0,5)=='drag ')
{
var dragged = document.getElementById(t.className.substr(5));
if (init==1)
{
cur_x_init = e.clientX;
cur_y_init = e.clientY;
dragged_x_init = dragged.offsetLeft;
dragged_y_init = dragged.offsetTop;
}
else
{
dragged_x = dragged.offsetLeft;
dragged_y = dragged.offsetTop;
cur_x_dif = e.clientX - cur_x_init;
cur_y_dif = e.clientY - cur_y_init;
dragged_half = dragged.clientWidth/2;
dragged_x_new = dragged_x_init+cur_x_dif+dragged_half;
dragged.style.left = dragged_x_new+'px';
//dragged.style.top = dragged_y_init + t+'px';
}
document.getElementById('status').value='cur_x_init = '+cur_x_init+'\ncur_x = '+
e.clientX+'\ncur_x_dif = '+cur_x_dif+'\ndragged_x_init = '+dragged_x_init+'\ndragged_x_new = '+dragged_x_new;
//document.getElementById('status').value='Init: '+init+'\nCur Init X: '+
//cur_x_init+'\nCur Init Y: '+cur_y_init+'\nCur X: '+e.clientX+'\nCur Y: '+
//e.clientY+'\nDragged Init X: '+dragged_x_init+'\nDragged Init Y: '+
//dragged_y_init+'\nDragged Left: '+dragged_x+'\nDragged Top: '+
//dragged_y+'\n'+init_dif_x+'\n'+init_dif_y;
var re = false;
}
else {re = true;}
return re;
}
//]]>
</script>
<style type="text/css">
#prompts {background: #ccc; border: solid 1px; border-color: #ccc #aaa #aaa #ccc;
height: 398px; left: 50%; margin-top: -198px; margin-left: -369px; position: absolute;
top: 50%; width: 738px; z-index: 3;}
#prompts h2 {background-color: #ddd; height: 20px; line-height: 20px; margin: 0px; text-align: center;}
#prompts h2 span {display: block; text-align: center; width: 738px;}
#prompts textarea {height: 373px; width: 734px;}
</style>
</head>
<body>
<div id="prompts">
<h2><span class="drag prompts">Title - This is the Drag Handle</span></h2>
<textarea id="status"></textarea>
</div>
</body>
</html>
[edited by: Fotiman at 1:47 pm (utc) on Sep 3, 2010]
[edit reason] Breaking up long lines [/edit]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DHTML</title>
<script type="text/javascript">
//<![CDATA[
var drag = {drag: 0};
document.onmousedown=function(e) {drag.drag = 1; move(e,1);};
document.onmousemove=function(e) {if (drag.drag==1) {move(e,0);}};
document.onmouseup=function() {drag.drag = 0; /*document.getElementById('status').value='0';*/};
var cur_x_init = 0;
var cur_y_init = 0;
var cur_x_dif = 0;
var cur_y_dif = 0;
var dragged_x_init = 0;
var dragged_y_init = 0;
function move(e,init)
{
if (!e) {e = window.event;}//IE6 OR: if (document.all) {e = window.event;}//IE6
if (e.target) {var t = e.target; var ie = false;}
else if (e.srcElement) {var t = e.srcElement; var ie = true;}
if (t.className.substr(0,5)=='drag ')
{
var dragged = document.getElementById(t.className.substr(5));
if (init==1)
{
cur_x_init = e.clientX;
cur_y_init = e.clientY;
dragged_x_init = dragged.offsetLeft;
dragged_y_init = dragged.offsetTop;
var dragged_x_new = 0;
var dragged_y_new = 0;
}
else
{
cur_x_dif = e.clientX - cur_x_init;
cur_y_dif = e.clientY - cur_y_init;
var dragged_x_half = dragged.clientWidth/2;
var dragged_y_half = dragged.clientHeight/2;
var dragged_x_new = dragged_x_init+cur_x_dif+dragged_x_half;
var dragged_y_new = dragged_y_init+cur_y_dif+dragged_y_half;
dragged.style.left = dragged_x_new+'px';
dragged.style.top = dragged_y_new+'px';
}
document.getElementById('status').value='ID = '+
t.className.substr(5)+'\ncur_x_init = '+cur_x_init+'\ncur_x = '+
e.clientX+'\ncur_x_dif = '+cur_x_dif+'\ndragged_x_init = '+
dragged_x_init+'\ndragged_x_new = '+dragged_x_new;
var re = false;
}
else {re = true;}
return re;
}
//]]>
</script>
<style type="text/css">
body {overflow: hidden;}
.drag {cursor: move;}
div.prompts {background: #ccc; border: solid 1px; border-color: #ccc #aaa #aaa #ccc;
height: 398px; margin-top: -198px; margin-left: -369px; position: absolute;
width: 738px;}
div.prompts h2 {background-color: #ddd; height: 20px; line-height: 20px; margin: 0px; text-align: center;}
div.prompts h2:hover {background-color: #fc6;}
div.prompts h2 span {display: block; text-align: center; width: 738px;}
div.prompts textarea {height: 373px; width: 732px;}
#prompt1 {left: 50%; top: 50%; z-index: 3;}
#prompt2 {background-color: #fdd; left: 55%; top: 55%; z-index: 2;}
#prompt3 {background-color: #dfd; left: 60%; top: 60%; z-index: 1;}
#prompt4 {background-color: #ddf; left: 65%; top: 65%; z-index: 0;}
</style>
<!--[if lte IE 7]><style type="text/css">div.prompts textarea {float: right;}</style><![endif]-->
</head>
<body>
<div class="prompts" id="prompt1"><h2><span class="drag prompt1">Prompt 1 - This is the Drag Handle</span></h2><textarea id="status"></textarea></div>
<div class="prompts" id="prompt2"><h2><span class="drag prompt2">Prompt 2 - This is the Drag Handle</span></h2></div>
<div class="prompts" id="prompt3"><h2><span class="drag prompt3">Prompt 3 - This is the Drag Handle</span></h2></div>
<div class="prompts" id="prompt4"><h2><span class="drag prompt4">Prompt 4 - This is the Drag Handle</span></h2></div>
</body>
</html>
[edited by: Fotiman at 1:48 pm (utc) on Sep 3, 2010]
[edit reason] Breaking up long lines [/edit]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DHTML</title>
<style type="text/css">
body {
overflow: hidden;
}
.drag {
cursor: move;
}
div.prompts {
background: #ccc;
border: solid 1px;
border-color: #ccc #aaa #aaa #ccc;
height: 398px;
margin-top: -198px;
margin-left: -369px;
position: absolute;
width: 738px;
}
div.prompts h2 {
background-color: #ddd;
height: 20px;
line-height: 20px;
margin: 0px;
text-align: center;
}
div.prompts h2:hover {
background-color: #fc6;
}
div.prompts h2 span {
display: block;
text-align: center;
width: 738px;
}
div.prompts textarea {
height: 373px;
width: 732px;
}
#prompt1 {
left: 50%;
top: 50%;
z-index: 3;
}
#prompt2 {
background-color: #fdd;
left: 55%;
top: 55%;
z-index: 2;
}
#prompt3 {
background-color: #dfd;
left: 60%;
top: 60%;
z-index: 1;
}
#prompt4 {
background-color: #ddf;
left: 65%;
top: 65%;
z-index: 0;
}
</style>
<!--[if lte IE 7]>
<style type="text/css">div.prompts textarea {float: right;}</style>
<![endif]-->
</head>
<body>
<div class="prompts" id="prompt1">
<h2><span class="drag prompt1">Prompt 1 - This is the Drag Handle</span></h2>
<textarea id="status"></textarea>
</div>
<div class="prompts" id="prompt2">
<h2><span class="drag prompt2">Prompt 2 - This is the Drag Handle</span></h2>
</div>
<div class="prompts" id="prompt3">
<h2><span class="drag prompt3">Prompt 3 - This is the Drag Handle</span></h2>
</div>
<div class="prompts" id="prompt4">
<h2><span class="drag prompt4">Prompt 4 - This is the Drag Handle</span></h2>
</div>
<script type="text/javascript">
//<![CDATA[
JAB_DD = {
init: function () {
var cur_x_dif = 0,
cur_x_init = 0,
cur_y_dif = 0,
cur_y_init = 0,
d = document,
drag = {drag: 0},
dragged_x_init = 0,
dragged_y_init = 0;
function move(e, init) {
var dragged,
dragged_x_half,
dragged_x_new,
dragged_y_half,
dragged_y_new,
ie,
re = true,
t;
if (!e) {
e = window.event;
}//IE6 OR: if (document.all) {e = window.event;}//IE6
if (e.target) {
t = e.target;
ie = false;
}
else if (e.srcElement) {
t = e.srcElement;
ie = true;
}
if (t.className.substr(0,5) == 'drag ') {
dragged = d.getElementById(t.className.substr(5));
if (init == 1) {
cur_x_init = e.clientX;
cur_y_init = e.clientY;
dragged_x_init = dragged.offsetLeft;
dragged_y_init = dragged.offsetTop;
dragged_x_new = 0;
dragged_y_new = 0;
}
else {
cur_x_dif = e.clientX - cur_x_init;
cur_y_dif = e.clientY - cur_y_init;
dragged_x_half = dragged.clientWidth / 2;
dragged_y_half = dragged.clientHeight / 2;
dragged_x_new = dragged_x_init + cur_x_dif + dragged_x_half;
dragged_y_new = dragged_y_init + cur_y_dif + dragged_y_half;
dragged.style.left = dragged_x_new + 'px';
dragged.style.top = dragged_y_new + 'px';
}
d.getElementById('status').value = 'ID = ' +
t.className.substr(5) + '\ncur_x_init = ' + cur_x_init +
'\ncur_x = ' + e.clientX +
'\ncur_x_dif = ' + cur_x_dif +
'\ndragged_x_init = ' + dragged_x_init +
'\ndragged_x_new = ' + dragged_x_new;
re = false;
}
return re;
}
// Attach event listeners
// TODO: Replace these event handlers with event listeners
d.onmousedown = function (e) {
drag.drag = 1;
move(e, 1);
};
d.onmousemove = function (e) {
if (drag.drag == 1) {
move(e, 0);
}
};
d.onmouseup = function () {
drag.drag = 0;
/*document.getElementById('status').value='0';*/
};
}
};
window.onload = JAB_DD.init;
//]]>
</script>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DHTML</title>
<script type="text/javascript">
//<![CDATA[
JAB_DD = {
init: function ()
{
var cur_x_dif = 0,
cur_x_init = 0,
cur_y_dif = 0,
cur_y_init = 0,
d = document,
drag = {drag: 0},
dragged_x_init = 0,
dragged_y_init = 0,
dragged_z = 0;
function move(e,init)
{
var dragged,dragged_x_half,dragged_x_new,dragged_y_half,dragged_y_new,ie,re=true,t,z;
if (!e) {e=window.event;}//IE6 OR: if (d.all) {e = window.event;}//IE6
if (e.target) {t=e.target; ie = false;}
else if (e.srcElement) {t=e.srcElement; ie = true;}
if (t.className.substr(0,5)=='drag ')
{
dragged = d.getElementById(t.className.substr(5));
if (init!=2)
{
if (init==1)
{
cur_x_init=e.clientX;
cur_y_init=e.clientY;
dragged_x_init=dragged.offsetLeft;
dragged_y_init=dragged.offsetTop;
dragged_x_new=0;
dragged_y_new=0;
if (dragged_z!=9001)
{
if (window.getComputedStyle) {z = d.defaultView.getComputedStyle(dragged,null).getPropertyValue('z-index');}
else if (dragged.currentStyle) {z = dragged.currentStyle['z-index'];}
if (z!=9001) {dragged_z=z;}
dragged = dragged.style.zIndex=9001;
}
}
else
{
cur_x_dif=e.clientX-cur_x_init;
cur_y_dif=e.clientY-cur_y_init;
dragged_x_half=dragged.clientWidth/2;
dragged_y_half=dragged.clientHeight/2;
dragged_x_new=dragged_x_init+cur_x_dif+dragged_x_half;
dragged_y_new=dragged_y_init+cur_y_dif+dragged_y_half;
dragged.style.left=dragged_x_new+'px';
dragged.style.top=dragged_y_new+'px';
}
d.getElementById('status').value = 'ID = '+t.className.substr(5)+'\ncur_x_init = '+cur_x_init+'\ncur_x = '+
e.clientX+'\ncur_x_dif = '+cur_x_dif+'\ndragged_x_init = '+
dragged_x_init+'\ndragged_x_new = '+dragged_x_new+'\ndragged_z = '+dragged_z;
re = false;
}
else {dragged.style.zIndex=dragged_z;}
}
return re;
}
// Attach event listeners
// TODO: Replace these event handlers with event listeners
d.onmousedown = function (e) {drag.drag=1; move(e,1);};
d.onmousemove = function (e) {if (drag.drag==1) {move(e,0);}};
d.onmouseup = function (e) {drag.drag=0;move(e,2);};
}
};
window.onload = JAB_DD.init;
//]]>
</script>
<style type="text/css">
body {overflow: hidden;}
.drag {cursor: move;}
div.prompts {background: #ccc; border: solid 1px; border-color: #ccc #aaa #aaa #ccc;
height: 398px; margin-top: -198px; margin-left: -369px; position: absolute; width: 738px;}
div.prompts h2 {background-color: #ddd; height: 20px; line-height: 20px; margin: 0px; text-align: center;}
div.prompts h2:hover {background-color: #fc6;}
div.prompts h2 span {display: block; text-align: center; width: 738px;}
div.prompts textarea {height: 373px; width: 732px;}
#prompt1 {left: 50%; top: 50%; z-index: 3;}
#prompt2 {background-color: #fdd; left: 55%; top: 55%; z-index: 2;}
#prompt3 {background-color: #dfd; left: 60%; top: 60%; z-index: 1;}
#prompt4 {background-color: #ddf; left: 65%; top: 65%; z-index: 0;}
</style>
<!--[if lte IE 7]><style type="text/css">div.prompts textarea {float: right;}</style><![endif]-->
</head>
<body>
<div class="prompts" id="prompt1">
<h2><span class="drag prompt1">Prompt 1 - This is the Drag Handle</span></h2><textarea id="status"></textarea>
</div>
<div class="prompts" id="prompt2">
<h2><span class="drag prompt2">Prompt 2 - This is the Drag Handle</span></h2>
</div>
<div class="prompts" id="prompt3">
<h2><span class="drag prompt3">Prompt 3 - This is the Drag Handle</span></h2>
</div>
<div class="prompts" id="prompt4">
<h2><span class="drag prompt4">Prompt 4 - This is the Drag Handle</span></h2>
</div>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>DHTML</title>
<script type="text/javascript">
//<![CDATA[
var drag = new function() {this.drag = 0;}
document.onmousedown=function(e) {drag.drag = 1; move(e,1);};
document.onmousemove=function(e) {if (drag.drag==1) {move(e,0);}};
document.onmouseup = function(e) {drag.drag=0;move(e,2);};
var cur_x_init = 0;
var cur_y_init = 0;
var cur_x_dif = 0;
var cur_y_dif = 0;
var dragged_x_init = 0;
var dragged_y_init = 0;
var dragged_z = 0;
function move(e,init)
{
var dragged,dragged_x_half,dragged_x_new,dragged_y_half,dragged_y_new,ie,re=true,t,z;
if (!e) {e = window.event;}//IE6 OR: if (document.all) {e = window.event;}//IE6
if (e.target) {var t = e.target; var ie = false;}
else if (e.srcElement) {var t = e.srcElement; var ie = true;}
if (t.className.substr(0,5)=='drag ')
{
dragged = document.getElementById(t.className.substr(5));
if (init!=2)
{
if (init==1)
{
cur_x_init=e.clientX;
cur_y_init=e.clientY;
dragged_x_init=dragged.offsetLeft;
dragged_y_init=dragged.offsetTop;
dragged_x_new=0;
dragged_y_new=0;
if (dragged_z!=9001)
{
if (window.getComputedStyle) {z = document.defaultView.getComputedStyle(dragged,null).getPropertyValue('z-index');}
else if (dragged.currentStyle) {z = dragged.currentStyle.zIndex;}
if (z!=9001) {dragged_z=z;}
dragged = dragged.style.zIndex=9001;
}
}
else
{
cur_x_dif=e.clientX-cur_x_init;
cur_y_dif=e.clientY-cur_y_init;
dragged_x_half=dragged.clientWidth/2;
dragged_y_half=dragged.clientHeight/2;
dragged_x_new=dragged_x_init+cur_x_dif+dragged_x_half;
dragged_y_new=dragged_y_init+cur_y_dif+dragged_y_half;
dragged.style.left=dragged_x_new+'px';
dragged.style.top=dragged_y_new+'px';
}
document.getElementById('status').value = 'ID = '+t.className.substr(5)+'\ncur_x_init =
'+cur_x_init+'\ncur_x = '+e.clientX+'\ncur_x_dif =
'+cur_x_dif+'\ndragged_x_init =
'+dragged_x_init+'\ndragged_x_new =
'+dragged_x_new+'\ndragged_z = '+dragged_z;
re = false;
}
else {document.getElementById(t.className.substr(5)).style.zIndex=dragged_z;}
}
else {re = true;}
return re;
}
//]]>
</script>
<style type="text/css">
body {overflow: hidden;}
.drag {cursor: move;}
div.prompts {background: #ccc; border: solid 1px; border-color: #ccc #aaa #aaa #ccc; height: 398px;
margin-top: -198px; margin-left: -369px; position: absolute; width: 738px;}
div.prompts h2 {background-color: #ddd; height: 20px;
line-height: 20px; margin: 0px; text-align: center;}
div.prompts h2:hover {background-color: #fc6;}
div.prompts h2 span {display: block; text-align: center; width: 738px;}
div.prompts textarea {height: 373px; width: 732px;}
#prompt1 {left: 50%; top: 50%; z-index: 3;}
#prompt2 {background-color: #fdd; left: 55%; top: 55%; z-index: 2;}
#prompt3 {background-color: #dfd; left: 60%; top: 60%; z-index: 1;}
#prompt4 {background-color: #ddf; left: 65%; top: 65%; z-index: 0;}
</style>
<!--[if lte IE 7]><style type="text/css">div.prompts textarea {float: right;}</style><![endif]-->
</head>
<body>
<div class="prompts" id="prompt1"><h2><span class="drag prompt1">Prompt 1 - This is the Drag Handle</span></h2><textarea id="status"></textarea></div>
<div class="prompts" id="prompt2"><h2><span class="drag prompt2">Prompt 2 - This is the Drag Handle</span></h2></div>
<div class="prompts" id="prompt3"><h2><span class="drag prompt3">Prompt 3 - This is the Drag Handle</span></h2></div>
<div class="prompts" id="prompt4"><h2><span class="drag prompt4">Prompt 4 - This is the Drag Handle</span></h2></div>
</body>
</html>