Login   Register  
PHP Classes
elePHPant
Icontem

File: js/fn_drag.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Francisco Caserio  >  cls_form  >  js/fn_drag.js  >  Download  
File: js/fn_drag.js
Role: Auxiliary script
Content type: text/plain
Description: drag object
Class: cls_form
Generate Web pages to manipulate database records
Author: By
Last change:
Date: 6 years ago
Size: 1,511 bytes
 

Contents

Class file image Download
// drag
var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;

function movemouse(e) {
    if (isdrag) {
        //dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
        //dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
        if (dobj.style.display == "block" ||
            dobj.style.display == "") {
            dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
            dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
            if (document.getElementById(dobj.id.replace("div_","iframe_"))) {
                document.getElementById(dobj.id.replace("div_","iframe_")).style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
                document.getElementById(dobj.id.replace("div_","iframe_")).style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
            }
        }
        return false;
    }
}

function selectmouse(e) {
    var fobj       = nn6 ? e.target : event.srcElement;
    var topelement = nn6 ? "HTML" : "BODY";
    while (fobj.tagName != topelement && fobj.className != "dragme") {
        fobj = nn6 ? fobj.parentNode : fobj.parentElement;
    }
    if (fobj.className=="dragme") {
        isdrag = true;
        dobj = fobj;
        tx = parseInt(dobj.style.left+0);
        ty = parseInt(dobj.style.top+0);
        x = nn6 ? e.clientX : event.clientX;
        y = nn6 ? e.clientY : event.clientY;
        document.onmousemove=movemouse;
        return false;
    }
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");