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-05-04 21:20:56 -04:00
|
|
|
|
2011-05-02 15:17:18 -04:00
|
|
|
|
2011-07-19 17:33:08 -04:00
|
|
|
if(window.addEventListener){
|
|
|
|
var BIND_HANDLER = "addEventListener";
|
|
|
|
var BIND_HANDLER_PREFIX = "";
|
|
|
|
}else if(window.attachEvent){
|
|
|
|
var BIND_HANDLER = "attachEvent";
|
|
|
|
var BIND_HANDLER_PREFIX = "on";
|
|
|
|
}
|
2011-05-01 11:43:13 -04:00
|
|
|
|
2011-07-19 17:33:08 -04:00
|
|
|
function getElementsByClassName(context, tag, cls){
|
|
|
|
var ele = context.getElementsByTagName(tag),
|
|
|
|
ret = [],
|
2011-07-20 08:32:27 -04:00
|
|
|
current,
|
|
|
|
classes;
|
2011-07-19 17:33:08 -04:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2011-07-17 15:28:18 -04:00
|
|
|
|
2011-07-19 17:33:08 -04:00
|
|
|
function addClass(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(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeClass(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(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function doFancyExpensiveTabThings(){
|
2011-07-21 12:12:37 -04:00
|
|
|
var tabs = (document.getElementsByClassName ? document.getElementsByClassName("tabs") : getElementsByClassName(document, "ul", "tabs"));
|
2011-07-19 17:33:08 -04:00
|
|
|
|
|
|
|
for(var i = 0, j = tabs.length; i < j; i++){
|
|
|
|
var tabList = tabs[i].getElementsByTagName('li');
|
|
|
|
for(var k = 0, l = tabList.length; k < l; k++){
|
2011-07-21 12:11:42 -04:00
|
|
|
tabList[k].getElementsByTagName('a')[0][BIND_HANDLER](BIND_HANDLER_PREFIX + "click", function(e){
|
|
|
|
var event = e || window.event;
|
|
|
|
return (function(e){
|
|
|
|
var contentLocation = this.href.substr(this.href.indexOf("#")) + "Tab",
|
2011-07-19 17:33:08 -04:00
|
|
|
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++){
|
|
|
|
removeClass(tabList[m].getElementsByTagName('a')[0], "active");
|
|
|
|
}
|
2011-07-21 12:11:42 -04:00
|
|
|
addClass(this, "active");
|
2011-07-19 17:33:08 -04:00
|
|
|
|
|
|
|
contentElement = document.getElementById(contentLocation.substr(1));
|
|
|
|
addClass(contentElement, "active");
|
|
|
|
|
|
|
|
siblings = contentElement.parentNode.getElementsByTagName('li');
|
|
|
|
for(m = 0, n = siblings.length; m < n; m++){
|
|
|
|
if(siblings[m] !== contentElement){
|
|
|
|
removeClass(siblings[m], "active");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2011-07-21 12:11:42 -04:00
|
|
|
}).call(event.target || event.srcElement, event);
|
|
|
|
}, false);
|
2011-07-19 17:33:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-19 18:02:32 -04:00
|
|
|
window[BIND_HANDLER](BIND_HANDLER_PREFIX + "load", doFancyExpensiveTabThings, false);
|