From c38615752c92ce47a993e4f888ae1d1e77d362d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Ste=CC=A8pien=CC=81?= Date: Tue, 24 Oct 2023 01:18:55 +0200 Subject: [PATCH] expose useToggleDisplay, minor changes --- _dev/js/theme/windowExpose.js | 3 ++- _dev/js/utils/display/useToggleDisplay.js | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/_dev/js/theme/windowExpose.js b/_dev/js/theme/windowExpose.js index df4c7de3..a7e8b353 100644 --- a/_dev/js/theme/windowExpose.js +++ b/_dev/js/theme/windowExpose.js @@ -7,6 +7,7 @@ import useHttpPayloadDefinition from "../utils/http/useHttpPayloadDefinition"; import { isElementVisible, each, DOMReady, parseToHtml } from '../utils/DOM/DOMHelpers'; import { getAllSiblingsBeforeElement, getAllSiblingsAfterElement } from '../utils/DOM/DOMSelectorsHelper'; import { fromSerializeObject, fromSerialize, formSerializeArray } from '../utils/form/formSerialize'; +import useToggleDisplay from "../utils/display/useToggleDisplay"; exposeToWindow('eventHandlerOn', on); exposeToWindow('eventHandlerOne', one); @@ -25,4 +26,4 @@ exposeToWindow('getAllSiblingsAfterElement', getAllSiblingsAfterElement); exposeToWindow('fromSerializeObject', fromSerializeObject); exposeToWindow('fromSerialize', fromSerialize); exposeToWindow('formSerializeArray', formSerializeArray); - +exposeToWindow('useToggleDisplay', useToggleDisplay); diff --git a/_dev/js/utils/display/useToggleDisplay.js b/_dev/js/utils/display/useToggleDisplay.js index be754ad9..ac479d73 100644 --- a/_dev/js/utils/display/useToggleDisplay.js +++ b/_dev/js/utils/display/useToggleDisplay.js @@ -1,6 +1,4 @@ -const useToggleDisplay = () => { - const D_NONE_CLASS = 'd-none'; - +const useToggleDisplay = (hideClass = 'd-none') => { /** * Show element * @param element {HTMLElement} Element to show @@ -8,7 +6,7 @@ const useToggleDisplay = () => { */ const show = (element) => { element.style.display = ''; - element.classList.remove(D_NONE_CLASS); + element.classList.remove(hideClass); }; /** @@ -18,7 +16,7 @@ const useToggleDisplay = () => { */ const hide = (element) => { element.style.display = ''; - element.classList.add(D_NONE_CLASS); + element.classList.add(hideClass); }; /**