-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.foundation.tabs.js
More file actions
36 lines (26 loc) · 987 Bytes
/
jquery.foundation.tabs.js
File metadata and controls
36 lines (26 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function ($) {
$.fn.foundationTabs = function (options) {
var settings = $.extend({
callback: $.noop
}, options);
var activateTab = function ($tab) {
var $activeTab = $tab.closest('dl').find('dd.active'),
contentLocation = $tab.children('a').attr("href") + 'Tab';
// Strip off the current url that IE adds
contentLocation = contentLocation.replace(/^.+#/, '#');
//Make Tab Active
$activeTab.removeClass('active');
$tab.addClass('active');
//Show Tab Content
$(contentLocation).closest('.tabs-content').children('li').removeClass('active').hide();
$(contentLocation).css('display', 'block').addClass('active');
};
$(document).on('click.fndtn', 'dl.tabs dd a', function (event){
activateTab($(this).parent('dd'));
});
if (window.location.hash) {
activateTab($('a[href="' + window.location.hash + '"]').parent('dd'));
settings.callback();
}
};
})(jQuery);