Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ $(function() {
|------|-------|-----------|
| selectorAttribute | false | Override the default `href` attribute used as selector when you need to activate multiple TabPanels at once with a single Tab using the `data-target` attribute. |
| backToTop |false | Prevent the page from jumping down to the tab content by setting the backToTop setting to true. |
| showParentTabs |false | Show the parent tabs so the selected tab comes into view if it is part of another tab grouping. |

NuGet package
=============
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-stickytabs",
"version": "1.2.3",
"version": "1.2.4",
"homepage": "https://github.com/aidanlister/jquery-stickytabs",
"authors": [
"Aidan Lister <[email protected]>"
Expand Down
20 changes: 16 additions & 4 deletions jquery.stickytabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* jQuery Plugin: Sticky Tabs
*
* @author Aidan Lister <[email protected]>
* @version 1.2.0
* @version 1.2.4
*/
(function ( $ ) {
$.fn.stickyTabs = function( options ) {
Expand All @@ -12,16 +12,28 @@
getHashCallback: function(hash, btn) { return hash },
selectorAttribute: "href",
backToTop: false,
showParentTabs: false,
initialTab: $('li.active > a', context)
}, options );

// Show the tab corresponding with the hash in the URL, or the first tab.
var showTabFromHash = function() {
var hash = settings.selectorAttribute == "href" ? window.location.hash : window.location.hash.substring(1);
if (hash != '') {
var selector = hash ? 'a[' + settings.selectorAttribute +'="' + hash + '"]' : settings.initialTab;
$(selector, context).tab('show');
setTimeout(backToTop, 1);
var selector = hash ? 'a[' + settings.selectorAttribute +'="' + hash + '"]' : settings.initialTab;
if (settings.showParentTabs === true) {
showParentTabs(hash);
}
$(selector, context).tab('show');
setTimeout(backToTop, 1);
}
}

var showParentTabs = function(hash) {
parent_hash = $('a[' + settings.selectorAttribute +'="' + hash + '"]').parents('.tab-pane').attr('id');
if (parent_hash !== undefined) {
$('a[' + settings.selectorAttribute +'="#' + parent_hash + '"]').tab('show');
showParentTabs('#' + parent_hash);
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-stickytabs",
"version": "1.2.3",
"version": "1.2.4",
"description": "jquery-stickytabs =================",
"main": "jquery.stickytabs.js",
"directories": {
Expand Down