diff --git a/assets/js/app.js b/assets/js/app.js index 652162a6..9d088440 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -43,7 +43,7 @@ require('bootstrap'); import "./sidebar" import "./datatables"; import "./error_handler"; -//import "./tab_remember"; +import "./tab_remember"; import "./register_events"; import "./tristate_checkboxes"; diff --git a/assets/js/datatables.js b/assets/js/datatables.js index 5166fa74..4c8c5236 100644 --- a/assets/js/datatables.js +++ b/assets/js/datatables.js @@ -17,7 +17,7 @@ import 'datatables.net-responsive-bs5'; import './lib/datatables'; -const DatatablesHelper = class { +class DatatablesHelper { constructor() { this.registerLoadHandler(() => this.initDataTables()); } diff --git a/assets/js/error_handler.js b/assets/js/error_handler.js index 25c5fa8f..573a0915 100644 --- a/assets/js/error_handler.js +++ b/assets/js/error_handler.js @@ -4,7 +4,7 @@ import * as bootbox from "bootbox"; * If this class is imported the user is shown an error dialog if he calls an page via Turbo and an error is responded. * @type {ErrorHandlerHelper} */ -const ErrorHandlerHelper = class { +class ErrorHandlerHelper { constructor() { console.log('Error Handler registered'); diff --git a/assets/js/register_events.js b/assets/js/register_events.js index 075966ac..b4510473 100644 --- a/assets/js/register_events.js +++ b/assets/js/register_events.js @@ -9,7 +9,7 @@ import "bootstrap-fileinput"; -const RegisterEventHelper = class { +class RegisterEventHelper { constructor() { this.registerTooltips(); this.registerJumpToTopBtn(); diff --git a/assets/js/sidebar.js b/assets/js/sidebar.js index 46d68c9a..e392e225 100644 --- a/assets/js/sidebar.js +++ b/assets/js/sidebar.js @@ -3,7 +3,7 @@ import "patternfly-bootstrap-treeview/src/css/bootstrap-treeview.css" import "patternfly-bootstrap-treeview"; -const SidebarHelper = class { +class SidebarHelper { constructor() { this.BASE = $("body").data("base-url"); //If path doesn't end with slash, add it. diff --git a/assets/js/tab_remember.js b/assets/js/tab_remember.js index e302a08d..46b9a1dd 100644 --- a/assets/js/tab_remember.js +++ b/assets/js/tab_remember.js @@ -5,42 +5,46 @@ * that tab on reload. That means that if the user changes something, he does not have to switch back to the tab * where he was before submit. */ -let TabRememberHelper = new class { +class TabRememberHelper { constructor() { - document.addEventListener("turbo:load", () => { - //Determine which tab should be shown (use hash if specified, otherwise use localstorage) - var $activeTab = null; - if (location.hash) { - $activeTab = $('a[href=\'' + location.hash + '\']'); - } else if (localStorage.getItem('activeTab')) { - $activeTab = $('a[href="' + localStorage.getItem('activeTab') + '"]'); - } + document.addEventListener("turbo:load", this.onLoad); + } - if ($activeTab) { - //Findout if the tab has any parent tab we have to show before - var parents = $($activeTab).parents('.tab-pane'); - parents.each(function (n) { - $('a[href="#' + $(this).attr('id') + '"]').tab('show'); - }); - //Finally show the active tab itself - $activeTab.tab('show'); - } - $('body').on('click', 'a[data-toggle=\'tab\']', function (e) { - e.preventDefault() - var tab_name = this.getAttribute('href') - if (history.replaceState) { - history.replaceState(null, null, tab_name) - } else { - location.hash = tab_name - } - localStorage.setItem('activeTab', tab_name) + onLoad(event) { + //Determine which tab should be shown (use hash if specified, otherwise use localstorage) + let $activeTab = null; + if (location.hash) { + $activeTab = $('a[href=\'' + location.hash + '\']'); + } else if (localStorage.getItem('activeTab')) { + $activeTab = $('a[href="' + localStorage.getItem('activeTab') + '"]'); + } - $(this).tab('show'); - return false; + if ($activeTab) { + //Findout if the tab has any parent tab we have to show before + var parents = $($activeTab).parents('.tab-pane'); + parents.each(function (n) { + $('a[href="#' + $(this).attr('id') + '"]').tab('show'); }); + //Finally show the active tab itself + $activeTab.tab('show'); + } + + $('body').on('click', 'a[data-bs-toggle=\'tab\']', function (e) { + e.preventDefault() + var tab_name = this.getAttribute('href') + if (history.replaceState) { + history.replaceState(null, null, tab_name) + } else { + location.hash = tab_name + } + localStorage.setItem('activeTab', tab_name) + + $(this).tab('show'); + return false; }); } + } -//export default new TabRememberHelper(); \ No newline at end of file +export default new TabRememberHelper(); \ No newline at end of file diff --git a/assets/js/tristate_checkboxes.js b/assets/js/tristate_checkboxes.js index 84d82380..6d78848e 100644 --- a/assets/js/tristate_checkboxes.js +++ b/assets/js/tristate_checkboxes.js @@ -2,7 +2,7 @@ import "./lib/jquery.tristate" -const TristateHelper = class { +class TristateHelper { constructor() { this.registerTriStateCheckboxes(); this.registerSubmitHandler();