From ee34b1fcb8f0af90e1f640c4ce1add246ab49d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Balicki?= Date: Tue, 5 Jan 2021 10:42:48 +0100 Subject: [PATCH 1/3] Open specific tab from hyperlink --- src/js/tab.js | 10 ++++++++++ src/js/tabler.js | 1 + 2 files changed, 11 insertions(+) create mode 100644 src/js/tab.js diff --git a/src/js/tab.js b/src/js/tab.js new file mode 100644 index 000000000..fcc293ec5 --- /dev/null +++ b/src/js/tab.js @@ -0,0 +1,10 @@ +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 bootstrap.Tab(tab).show(); + }); +} diff --git a/src/js/tabler.js b/src/js/tabler.js index f221ae301..940c64715 100644 --- a/src/js/tabler.js +++ b/src/js/tabler.js @@ -3,6 +3,7 @@ import './autosize'; import './input-mask'; import './dropdown'; +import './tab'; (function() { /** From e8d76372607767f06ae3b5040add58355098186c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Balicki?= Date: Tue, 5 Jan 2021 10:46:16 +0100 Subject: [PATCH 2/3] Space fix --- src/js/tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/tab.js b/src/js/tab.js index fcc293ec5..943329c4b 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -5,6 +5,6 @@ if (locationHash) { const matchedTabs = tabsList.filter(tab => tab.hash === locationHash); matchedTabs.map(tab => { - new bootstrap.Tab(tab).show(); + new bootstrap.Tab(tab).show(); }); } From 7806af21e3a3de222a9d519ff24d5b291df51811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Balicki?= Date: Sat, 10 Apr 2021 22:31:23 +0200 Subject: [PATCH 3/3] Tab activator as separated function --- src/js/src/tab.js | 14 ++++++++++++++ src/js/tab.js | 10 ---------- src/js/tabler.js | 2 ++ 3 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 src/js/src/tab.js delete mode 100644 src/js/tab.js diff --git a/src/js/src/tab.js b/src/js/src/tab.js new file mode 100644 index 000000000..a142c577e --- /dev/null +++ b/src/js/src/tab.js @@ -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(); + }); + } +} diff --git a/src/js/tab.js b/src/js/tab.js deleted file mode 100644 index 943329c4b..000000000 --- a/src/js/tab.js +++ /dev/null @@ -1,10 +0,0 @@ -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 bootstrap.Tab(tab).show(); - }); -} diff --git a/src/js/tabler.js b/src/js/tabler.js index c0e605828..9a3dae8ac 100644 --- a/src/js/tabler.js +++ b/src/js/tabler.js @@ -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();