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

Function showPreferences

src/core/api.js:256–289  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

254 * Show preferences modal
255 */
256export const showPreferences = () => {
257 const state = globalObj._state;
258
259 if (state._preferencesModalVisible)
260 return;
261
262 if (!state._preferencesModalExists)
263 createPreferencesModal(miniAPI, createMainContainer);
264
265 state._preferencesModalVisible = true;
266
267 // If there is no consent-modal, keep track of the last focused elem.
268 if (!state._consentModalVisible) {
269 state._lastFocusedElemBeforeModal = getActiveElement();
270 } else {
271 state._lastFocusedModalElement = getActiveElement();
272 }
273
274 focusAfterTransition(globalObj._dom._pm, 2);
275
276 addClass(globalObj._dom._htmlDom, TOGGLE_PREFERENCES_MODAL_CLASS);
277 setAttribute(globalObj._dom._pm, ARIA_HIDDEN, 'false');
278
279 /**
280 * Set focus to preferencesModal
281 */
282 setTimeout(() => {
283 focus(globalObj._dom._pmDivTabindex);
284 }, 100);
285
286 debug('CookieConsent [TOGGLE]: show preferencesModal');
287
288 fireEvent(globalObj._customEvents._onModalShow, PREFERENCES_MODAL_NAME);
289};
290
291/**
292 * https://github.com/orestbida/cookieconsent/issues/481

Callers 1

addDataButtonListenersFunction · 0.85

Calls 8

getActiveElementFunction · 0.90
focusAfterTransitionFunction · 0.90
addClassFunction · 0.90
setAttributeFunction · 0.90
focusFunction · 0.90
debugFunction · 0.90
fireEventFunction · 0.90
createPreferencesModalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…