bit dojo labs : file explorer
Inspecting: home > js > linksfx > linksfx.js (download)////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// LinkSfx JS v0.6, 2007/05/01
//
// Copyright (c) 2007 Alan Peng ( http://bitdojo.net )
//
// This JavaScript adds a special effect to your links when clicked.
// The original "a" html tag does not need to be changed.
// Links which have a "rel" attribute are not modified, so scripts like LightBox should still work.
//
// This script uses special effects library from Scriptaculous JS ( http://script.aculo.us )
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var LinkSfx = Class.create();
LinkSfx.prototype = {
initialize: function(){
this.addLinkEffects();
},
addLinkEffects: function(){
var links = document.getElementsByTagName("a");
for(var i = 0; i < links.length; i++){
var link = links[i];
var rel = link.getAttribute("rel");
if(!rel) {
link.onclick = function () {
myLinkSfx.sfxStart(this);
return false;
};
}
}
},
sfxStart: function(link) {
link.blur(); // to get rid of the ugly selection box
new Effect.Pulsate(link, {duration: 1.5});
var url = link.getAttribute("href");
var target = link.getAttribute("target");
var isNewWindow = (target == "_blank");
myLinkSfx.delayLink(url, false, isNewWindow);
return false;
},
delayLink: function(url, hasDelayed, isNewWindow){
if(hasDelayed){
if(!isNewWindow){
window.location = url;
} else {
window.open(url);
}
} else {
setTimeout("myLinkSfx.delayLink('" + url + "', true, "+ isNewWindow +")", 800);
}
}
}
function initLinkSfx() { myLinkSfx = new LinkSfx(); }
Event.observe(window, 'load', initLinkSfx, false);