TechMates
member?
If not be one of us!Join us guys!
Login if your a member!
Enjoy!

TechMates

Life is Useless without TechMates
 
HomePortalCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 Draggable Comment Data.(cool)

Go down 
AuthorMessage
JorgyRom
Admin
Admin
avatar

Posts : 49
Points : 78
Reputation : 3
Join date : 2009-07-26
Age : 26
Location : Manila

PostSubject: Draggable Comment Data.(cool)   Fri Jul 31, 2009 1:54 am

Just sharing some tricks!!
Credit: christiandelacruz09

Code:
try {
    sty = document.createElement("style");
    sty.type = "text/css";
    sty.innerHTML = ".data{position:relative;}";
    document.getElementsByTagName("head")[0].appendChild(sty);
}catch(e){}
try {
    document.styleSheets[document.styleSheets.length - 1].addRule(".data", "position:relative;");
}catch(e){}

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;
    return false;
  }
}

function selectmouse(e) {
  var fobj      = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  while (fobj.tagName != topelement && fobj.className != "data") {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }

  if (fobj.className=="data") {
    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");

var disprimpic = getElementsByClassName(null,"div","data")[0];
disprimpic.innerHTML = disprimpic.innerHTML.replace(/<a[\S\s]+?>/i,"").replace(/<\/a>/,"");

function getElementsByClassName(oElm,sTag,sClass) {
        var elm = [];
        if (!oElm)oElm = document;
        if (!sTag)sTag = "*";
    var els = oElm.getElementsByTagName(sTag) || document.all;
            for (var j=0,k=els.length;j<k;j++) {
                if (new RegExp(sClass).test(els[j].className)) {
                    elm.push(els[j]);
                }
            }
            return elm;
}


Add the codes to your Javascript file..

_________________
"Life is Useless Without Techmates"

http://profiles.friendster.com/111675865

How to make JS(javascript) File?
Click here

How to make CSS(cascading style sheets file)?
Click here
Back to top Go down
View user profile
 
Draggable Comment Data.(cool)
Back to top 
Page 1 of 1
 Similar topics
-
» Cool new 1/35 scale sci-fi/Girly figures....
» Team Natsuki (We're too Cool for YOU)
» Pretty cool 4 door to 2 door conversion (older Impala)
» Cool youtube channel with a lot of vintage raw local police/fire video
» Just saw this on ebay. Pretty cool woody paint.

Permissions in this forum:You cannot reply to topics in this forum
TechMates :: Friendster Design and Development :: Friendster Tricks and Tutorials :: JavaScript-
Jump to: