Skip to content

Commit

Permalink
expose useToggleDisplay, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksydan committed Oct 23, 2023
1 parent a4ea6ee commit c386157
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion _dev/js/theme/windowExpose.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useHttpPayloadDefinition from "../utils/http/useHttpPayloadDefinition";
import { isElementVisible, each, DOMReady, parseToHtml } from '../utils/DOM/DOMHelpers';

Check failure on line 7 in _dev/js/theme/windowExpose.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Expected a line break after this opening brace

Check failure on line 7 in _dev/js/theme/windowExpose.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Expected a line break after this opening brace
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);
Expand All @@ -25,4 +26,4 @@ exposeToWindow('getAllSiblingsAfterElement', getAllSiblingsAfterElement);
exposeToWindow('fromSerializeObject', fromSerializeObject);
exposeToWindow('fromSerialize', fromSerialize);
exposeToWindow('formSerializeArray', formSerializeArray);

exposeToWindow('useToggleDisplay', useToggleDisplay);
8 changes: 3 additions & 5 deletions _dev/js/utils/display/useToggleDisplay.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const useToggleDisplay = () => {
const D_NONE_CLASS = 'd-none';

const useToggleDisplay = (hideClass = 'd-none') => {
/**
* Show element
* @param element {HTMLElement} Element to show
* @returns {void}
*/
const show = (element) => {
element.style.display = '';
element.classList.remove(D_NONE_CLASS);
element.classList.remove(hideClass);
};

/**
Expand All @@ -18,7 +16,7 @@ const useToggleDisplay = () => {
*/
const hide = (element) => {
element.style.display = '';
element.classList.add(D_NONE_CLASS);
element.classList.add(hideClass);
};

/**
Expand Down

0 comments on commit c386157

Please sign in to comment.