1 SHAKING PRIMARY IMAGE Sat Dec 06, 2008 10:41 am
danilodeleon
Administrative Team
Description:Your Primary Image will shake on mouse over and will stop on mouse out.
LIVE PREVIEW:
http://profiles.friendster.com/91075052
CODE:
if (!attachOnLoadHandler(function() { SHAKEIMG.init();})) window.onload = function() { SHAKEIMG.init();};
if (typeof SHAKEIMG == "undefined") { SHAKEIMG = {}; }
SHAKEIMG = {
stopIt: 0,
stopAt: 1,
deg: 3,
classShake: function() {
try {
sty = document.createElement("style");
sty.type = "text/css";
sty.innerHTML = ".shakeIt{position:relative;}";
document.getElementsByTagName("head")[0].appendChild(sty);
}catch(e){}
try {
document.styleSheets[document.styleSheets.length - 1].addRule(".shakeIt", "position:relative;");
}catch(e){}
},
init: function() {
imgSrc = this.getModuleByClassName(/imgblock200/i)[0].getElementsByTagName("img")[0].getAttribute("src");
getSrc = this.getModuleByClassName(/imgblock200/i)[0].getElementsByTagName("a")[0];
getSrc.innerHTML = "<img src=\""+imgSrc+"\" class=\"shakeIt\" onMouseover=\"SHAKEIMG.initshake(this);SHAKEIMG.rattleimage()\" onMouseout=\"SHAKEIMG.stoprattle(this);top.focus()\" onClick=\"top.focus()\">";
SHAKEIMG.classShake();
},
initshake: function(x) {
this.stopIt = 0;
goyang = x;
goyang.style.left = 0;
goyang.style.top = 0;
},
rattleimage: function() {
if ((!document.all && !document.getElementById) || this.stopIt == 1) {
return;
}
if (this.stopAt == 1) {
goyang.style.top = parseInt(goyang.style.top)+this.deg;
}else if (this.stopAt == 2) {
goyang.style.left = parseInt(goyang.style.left)+this.deg;
}else if (this.stopAt == 3) {
goyang.style.top = parseInt(goyang.style.top)-this.deg;
}else {
goyang.style.left = parseInt(goyang.style.left)-this.deg;
}
if (this.stopAt < 4) {
this.stopAt++;
}else {
this.stopAt = 1;
}
setTimeout("SHAKEIMG.rattleimage()",50);
},
stoprattle: function(x) {
this.stopIt = 1;
x.style.left = 0;
x.style.top = 0;
},
getModuleByClassName: function(sClass) {
var elm = [];
var els = document.getElementsByTagName("*") || 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;
}
};
SORRY ADMINS,BUT I HATE USING SPOILER
JUST PLACE THE CODE IN YOUR JS FILE.
LIVE PREVIEW:
http://profiles.friendster.com/91075052
CODE:
if (!attachOnLoadHandler(function() { SHAKEIMG.init();})) window.onload = function() { SHAKEIMG.init();};
if (typeof SHAKEIMG == "undefined") { SHAKEIMG = {}; }
SHAKEIMG = {
stopIt: 0,
stopAt: 1,
deg: 3,
classShake: function() {
try {
sty = document.createElement("style");
sty.type = "text/css";
sty.innerHTML = ".shakeIt{position:relative;}";
document.getElementsByTagName("head")[0].appendChild(sty);
}catch(e){}
try {
document.styleSheets[document.styleSheets.length - 1].addRule(".shakeIt", "position:relative;");
}catch(e){}
},
init: function() {
imgSrc = this.getModuleByClassName(/imgblock200/i)[0].getElementsByTagName("img")[0].getAttribute("src");
getSrc = this.getModuleByClassName(/imgblock200/i)[0].getElementsByTagName("a")[0];
getSrc.innerHTML = "<img src=\""+imgSrc+"\" class=\"shakeIt\" onMouseover=\"SHAKEIMG.initshake(this);SHAKEIMG.rattleimage()\" onMouseout=\"SHAKEIMG.stoprattle(this);top.focus()\" onClick=\"top.focus()\">";
SHAKEIMG.classShake();
},
initshake: function(x) {
this.stopIt = 0;
goyang = x;
goyang.style.left = 0;
goyang.style.top = 0;
},
rattleimage: function() {
if ((!document.all && !document.getElementById) || this.stopIt == 1) {
return;
}
if (this.stopAt == 1) {
goyang.style.top = parseInt(goyang.style.top)+this.deg;
}else if (this.stopAt == 2) {
goyang.style.left = parseInt(goyang.style.left)+this.deg;
}else if (this.stopAt == 3) {
goyang.style.top = parseInt(goyang.style.top)-this.deg;
}else {
goyang.style.left = parseInt(goyang.style.left)-this.deg;
}
if (this.stopAt < 4) {
this.stopAt++;
}else {
this.stopAt = 1;
}
setTimeout("SHAKEIMG.rattleimage()",50);
},
stoprattle: function(x) {
this.stopIt = 1;
x.style.left = 0;
x.style.top = 0;
},
getModuleByClassName: function(sClass) {
var elm = [];
var els = document.getElementsByTagName("*") || 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;
}
};
SORRY ADMINS,BUT I HATE USING SPOILER
JUST PLACE THE CODE IN YOUR JS FILE.