Skip to content

Commit

Permalink
Tab activator as separated function
Browse files Browse the repository at this point in the history
  • Loading branch information
kilab committed Apr 10, 2021
1 parent 0f2124f commit 7806af2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
14 changes: 14 additions & 0 deletions src/js/src/tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Tab } from 'bootstrap';

export const EnableActivationTabsFromLocationHash = () => {
const locationHash = window.location.hash;

if (locationHash) {
const tabsList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tab"]'));
const matchedTabs = tabsList.filter(tab => tab.hash === locationHash);

matchedTabs.map(tab => {
new Tab(tab).show();
});
}
}
10 changes: 0 additions & 10 deletions src/js/tab.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/js/tabler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ import './src/dropdown';
import './src/tooltip';
import './src/popover';
import './src/switch-icon';
import { EnableActivationTabsFromLocationHash } from './src/tab';
import './src/toast';

EnableActivationTabsFromLocationHash();

0 comments on commit 7806af2

Please sign in to comment.