MCPcopy
hub / github.com/orestbida/cookieconsent / show

Function show

src/core/api.js:183–218  ·  view source on GitHub ↗
(createModal)

Source from the content-addressed store, hash-verified

181 * @param {boolean} [createModal] create modal if it doesn't exist
182 */
183export const show = (createModal) => {
184 const { _dom, _state } = globalObj;
185
186 if (_state._consentModalVisible)
187 return;
188
189 if (!_state._consentModalExists) {
190 if (createModal) {
191 createConsentModal(miniAPI, createMainContainer);
192 } else {
193 return;
194 }
195 }
196
197 _state._consentModalVisible = true;
198 _state._lastFocusedElemBeforeModal = getActiveElement();
199
200 if (_state._disablePageInteraction)
201 toggleDisableInteraction(true);
202
203 focusAfterTransition(_dom._cm, 1);
204
205 addClass(_dom._htmlDom, TOGGLE_CONSENT_MODAL_CLASS);
206 setAttribute(_dom._cm, ARIA_HIDDEN, 'false');
207
208 /**
209 * Set focus to consentModal
210 */
211 setTimeout(() => {
212 focus(globalObj._dom._cmDivTabindex);
213 }, 100);
214
215 debug('CookieConsent [TOGGLE]: show consentModal');
216
217 fireEvent(globalObj._customEvents._onModalShow, CONSENT_MODAL_NAME);
218};
219
220/**
221 * Hide consent modal

Callers 2

addDataButtonListenersFunction · 0.85
runFunction · 0.85

Calls 9

getActiveElementFunction · 0.90
toggleDisableInteractionFunction · 0.90
focusAfterTransitionFunction · 0.90
addClassFunction · 0.90
setAttributeFunction · 0.90
focusFunction · 0.90
debugFunction · 0.90
fireEventFunction · 0.90
createConsentModalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…