(createModal)
| 181 | * @param {boolean} [createModal] create modal if it doesn't exist |
| 182 | */ |
| 183 | export 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 |
no test coverage detected
searching dependent graphs…