Bones/javascripts/tabs.js

30 lines
755 B
JavaScript
Raw Normal View History

2012-03-01 17:30:57 -05:00
/**
* Skeleton V1.1
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 8/17/2011
*/
2011-08-17 21:37:35 -04:00
2012-03-01 17:53:51 -05:00
(function ($) {
// hash change handler
function hashchange () {
var hash = window.location.hash
, el = $('ul.tabs [href*="' + hash + '"]')
2012-03-01 17:53:51 -05:00
, content = $(hash)
2011-08-17 21:37:35 -04:00
2012-03-01 17:53:51 -05:00
if (el.length && !el.hasClass('active') && content.length) {
el.closest('.tabs').find('.active').removeClass('active');
el.addClass('active');
content.show().addClass('active').siblings().hide().removeClass('active');
}
}
// listen on event and fire right away
$(window).on('hashchange.skeleton', hashchange);
hashchange();
2012-03-01 17:53:51 -05:00
$(hashchange);
})(jQuery);