From 76be30c318bfd1f8899222629a950c6595c4e658 Mon Sep 17 00:00:00 2001 From: Brian Hogan Date: Sat, 13 Aug 2011 12:22:18 -0500 Subject: [PATCH] modified the tab behavior so it works when JS is disabled but CSS is enabled, an accessibility edge-case --- javascripts/app.js | 13 ++++++++++++- stylesheets/base.css | 1 - 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/javascripts/app.js b/javascripts/app.js index 38fb78a..98f6374 100644 --- a/javascripts/app.js +++ b/javascripts/app.js @@ -15,13 +15,24 @@ $(document).ready(function() { ================================================== */ var tabs = $('ul.tabs'); + /* hide tab content. Doing this with JS + makes the tabs work when JS is enabled but + CSS is not, an interesting accessibility + edge case. Ensures that "active" is respected. + */ + $("ul.tabs-content > li").each(function(t){ + if(!$(this).hasClass("active")){ + $(this).hide(); + }; + }); + tabs.each(function(i) { //Get all tabs var tab = $(this).find('> li > a'); tab.click(function(e) { //Get Location of tab's content - var contentLocation = $(this).attr('href') + "Tab"; + var contentLocation = $(this).attr('href'); //Let go if not a hashed one if(contentLocation.charAt(0)=="#") { diff --git a/stylesheets/base.css b/stylesheets/base.css index 0496b54..e3c2cfc 100644 --- a/stylesheets/base.css +++ b/stylesheets/base.css @@ -254,7 +254,6 @@ border-top-right-radius: 2px; } ul.tabs-content { margin: 0; display: block; } - ul.tabs-content > li { display:none; } ul.tabs-content > li.active { display: block; } /* Clearfixing tabs for beautiful stacking */