Bones/javascripts/app.js
Mauvis Ledford f31daea627 Tab JS optimizations:
- Use jQuery.live so that even if tabs are ajaxed in they still work.
- Don't use DOM ready since this JS file is already at the bottom of the page.
- Remove selected class only on sibling tabs.
- Don't add a selected class on selected tab if it's already there (avoid hits to the DOM).
- Avoid using $(this) a lot, and instead use a saved reference, as you're creating a new jQuery object each time.
- Use '$' in front of jQuery variables so that you know they are jQuery objects.
2011-07-31 12:36:20 -07:00

34 lines
871 B
JavaScript

/*
* Skeleton V1.0.3
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 7/17/2011
*/
/* Tabs Activiation
================================================= */
$('ul.tabs > li').live('click', function(e) {
var $tab = $(this);
var $href = $tab.find('a:first');
var $otherHrefs = $tab.siblings().find('a');
var contentLocation = $href.attr('href') + "Tab";
//Let go if not a hashed one
if(contentLocation[0]=="#") {
e.preventDefault();
$otherHrefs.removeClass('active');
//Make Tab Active
if (!$href.hasClass('active')){
$href.addClass('active');
}
//Show Tab Content & add active class
$(contentLocation).show().addClass('active').siblings().hide().removeClass('active');
}
});