2011-05-03 10:36:26 -04:00
|
|
|
/*
|
2011-07-17 15:28:18 -04:00
|
|
|
* Skeleton V1.0.3
|
2011-05-19 15:05:30 -04:00
|
|
|
* Copyright 2011, Dave Gamache
|
2011-05-15 20:02:52 -04:00
|
|
|
* www.getskeleton.com
|
2011-05-19 15:05:30 -04:00
|
|
|
* Free to use under the MIT license.
|
|
|
|
* http://www.opensource.org/licenses/mit-license.php
|
2011-07-17 15:28:18 -04:00
|
|
|
* 7/17/2011
|
2011-07-19 17:33:08 -04:00
|
|
|
* un-jQuerified by Eric Kever
|
2011-05-03 10:36:26 -04:00
|
|
|
*/
|
2011-07-17 15:28:18 -04:00
|
|
|
|
2011-08-10 13:20:52 -04:00
|
|
|
(function(){
|
|
|
|
var Skeleton = {
|
|
|
|
getElementsByClassName : function(context, cls){
|
|
|
|
if(context.getElementsByClassName){
|
|
|
|
return context.getElementsByClassName(cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
var ele = context.getElementsByTagName("*"),
|
|
|
|
ret = [],
|
|
|
|
current,
|
|
|
|
classes;
|
|
|
|
|
|
|
|
for(var i = 0, j = ele.length; i < j; i++){
|
|
|
|
current = ele[i];
|
|
|
|
classes = (current.getAttribute("className") || current.className).split(" ");
|
|
|
|
for(var k = 0, l = classes.length; k < l; k++){
|
|
|
|
if(classes[k] === cls){
|
|
|
|
ret.push(current);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
|
|
|
filterTags : function(list, tags){
|
|
|
|
var exists = false;
|
|
|
|
|
|
|
|
for(var i = 0, j = list.length; i < j; i++){
|
|
|
|
for(var k = 0, l = tags.length; k < l; k++){
|
|
|
|
if(list[i].tagName === tags[k]){
|
|
|
|
exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(exists === true){
|
|
|
|
list.splice(i, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
|
|
|
addClass : function(element, name){
|
|
|
|
var classes = (element.getAttribute("className") || element.className).split(" "),
|
|
|
|
exists = false;
|
|
|
|
|
|
|
|
for(i = 0, j = classes.length; i < j; i++){
|
|
|
|
if(classes[i] === name){
|
|
|
|
exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!exists){
|
|
|
|
classes.push(name);
|
|
|
|
element.className = classes.join(" ");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
removeClass : function(element, name){
|
|
|
|
var classes = (element.getAttribute("className") || element.className).split(" "),
|
|
|
|
exists = false;
|
|
|
|
|
|
|
|
for(var i = 0, j = classes.length; i < j; i++){
|
|
|
|
if(classes[i] === name){
|
|
|
|
exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(exists){
|
|
|
|
classes.splice(i, 1);
|
|
|
|
element.className = classes.join(" ");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
addListener : function(element, on, fn, last){
|
|
|
|
last = (last || false);
|
|
|
|
var BH;
|
|
|
|
|
|
|
|
if(window.addEventListener){ //AddEventListener takes precedence here
|
|
|
|
BH = "addEventListener";
|
|
|
|
}else if(window.attachEvent){
|
|
|
|
BH = "attachEvent";
|
|
|
|
on = "on" + on;
|
|
|
|
}
|
|
|
|
|
|
|
|
element[BH](on, function(e){
|
|
|
|
var event = e || window.event;
|
|
|
|
return fn.call(element, event); //Force it to call the handler in the proper context (IE 7 & 8 do not)
|
|
|
|
}, last);
|
2011-08-10 15:01:06 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
doFancyExpensiveTabThings : function(){
|
|
|
|
var tabs = Skeleton.filterTags(Skeleton.getElementsByClassName(document, "tabs"), ["ul"]);
|
|
|
|
|
|
|
|
for(var i = 0, j = tabs.length; i < j; i++){
|
|
|
|
(function(){
|
|
|
|
var tabNum = i,
|
|
|
|
tabList = tabs[tabNum].getElementsByTagName("li");
|
|
|
|
|
|
|
|
for(var k = 0, l = tabList.length; k < l; k++){
|
2011-08-12 13:20:03 -04:00
|
|
|
Skeleton.addListener(tabList[k].getElementsByTagName("a")[0], "click", function(e){
|
2011-08-10 15:01:06 -04:00
|
|
|
var contentLocation = this.href.substr(this.href.indexOf("#")) + "Tab",
|
|
|
|
contentElement,
|
|
|
|
siblings;
|
|
|
|
|
|
|
|
if(contentLocation.charAt(0) === "#"){
|
|
|
|
if(e.preventDefault){
|
|
|
|
e.preventDefault();
|
|
|
|
}else{
|
|
|
|
e.returnValue = false;
|
|
|
|
e.cancelBubble = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(var m = 0; m < k; m++){
|
2011-08-12 13:20:03 -04:00
|
|
|
Skeleton.removeClass(tabList[m].getElementsByTagName("a")[0], "active");
|
2011-08-10 15:01:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Skeleton.addClass(this, "active");
|
|
|
|
|
|
|
|
//contentElement = document.getElementById(contentLocation.substr(1));
|
|
|
|
contentElement = Skeleton.getElementsByClassName(Skeleton.getElementsByClassName(tabs[tabNum].parentNode, "tabs-content")[0], contentLocation.substr(1))[0];
|
|
|
|
Skeleton.addClass(contentElement, "active");
|
|
|
|
|
2011-08-12 13:20:03 -04:00
|
|
|
siblings = contentElement.parentNode.getElementsByTagName("li");
|
|
|
|
for(var m = 0, n = siblings.length; m < n; m++){
|
2011-08-10 15:01:06 -04:00
|
|
|
if(siblings[m] !== contentElement){
|
|
|
|
Skeleton.removeClass(siblings[m], "active");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
}
|
2011-08-12 13:20:03 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
html5 : {
|
|
|
|
managedElements : [],
|
|
|
|
inputElements : [],
|
|
|
|
|
|
|
|
create : {
|
|
|
|
element : function(element, type){
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
color : function(){
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
loader : function(){
|
|
|
|
Skeleton.html5.inputElements = document.getElementsByTagName("input");
|
|
|
|
|
|
|
|
for(var i = 0, j = Skeleton.html5.inputElements.length; i < j; i++){
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2011-08-10 13:20:52 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.Skeleton = Skeleton;
|
|
|
|
})();
|
2011-07-19 17:33:08 -04:00
|
|
|
|
2011-08-10 15:01:06 -04:00
|
|
|
Skeleton.addListener(window, "load", Skeleton.doFancyExpensiveTabThings);
|