()
| 254 | * Show preferences modal |
| 255 | */ |
| 256 | export 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 |
no test coverage detected
searching dependent graphs…