Created
August 14, 2011 16:18
-
-
Save walterdavis/1145031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var box = $('yourHTMLBox'); | |
var tabs = box.select('h3'); | |
var bodies = box.select('p,ul,dl,table'); | |
var tabStyle = 'background-color:#ccc'; | |
var tabSelected = 'background-color: #dd9' | |
tabs.invoke('setStyle','display:inline; padding:4px 8px; ' + tabStyle + '; margin:0; cursor:pointer'); | |
bodies.each(function(elm){ | |
elm.hide(); | |
elm._tab = elm.previous('h3'); | |
box.insert({bottom:elm.remove()}); | |
}); | |
tabs.first().setStyle(tabSelected); | |
tabs.invoke('observe','click',function(evt){ | |
bodies.invoke('hide'); | |
tabs.invoke('setStyle',tabStyle); | |
var tab = this; | |
tab.setStyle(tabSelected); | |
var bods = bodies.findAll(function(elm){ | |
return elm._tab == tab; | |
}); | |
bods.invoke('show'); | |
}); | |
bodies.findAll(function(elm){ | |
return elm._tab == tabs.first(); | |
}).invoke('show'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment