Code:
if(window.addEventListener){
window.addEventListener("load",EasySlideLoad,false);//W3C load advanced model
}
else if(window.attachEvent){
window.attachEvent("onload",EasySlideLoad);//IE advanced model
}
Don't forget to use window.onload = function(){}; as a backup. Also, be consistent with your semicolons: ECMAScript will insert a semicolon after that anonymous function (since it forms part of a statement).
Code:
this.parent.innerHTML += '<div class="EStitle">'+this.images[0].alt+'</div>';//Add the first title
Ouch... try:
Code:
var d = document.createElement("div");
d.className = "EStitle";
d.appendChild(document.createTextNode(this.images[0].alt));
this.parent.appendChild(d);
innerHTML is non-standard and should be avoided where possible.
Code:
EasySlide.prototype.getConfig = function(name,default_val){
var classname = this.parent.className;//Store the classname
var array = classname.split(name+'(');//split the string at the config name
if(array.length > 1){//make sure it existed
var temp = array[1];//store almost what we want
return temp.split(')')[0];//cut off the extra and return it
}
else{
return default_val;//Variable is not included. return the default
}
}
Easier:
Code:
EasySlide.prototype.getConfig = function(name,default_val){
var m = this.parent.className.match(new RegExp("\\b" + name + "\\(([^\\)]+)\\)"));
if(m) return m[1];
else return default_val;
}
There are two other problems I have with it: a) it should be possible to set the colour of the title on a per-slide basis, since different slides with have different backgrounds, and b) the slide effect doesn't work in KHTML/KJS (the fade doesn't either, but it degrades nicely; the slide simply doesn't show anything).
Other than that, great work! I'm impressed.
Bookmarks