1 2; /* Start:"a:4:{s:4:"full";s:83:"/bitrix/components/s34web/cookiesnotify/templates/.default/script.js?17775385766229";s:6:"source";s:68:"/bitrix/components/s34web/cookiesnotify/templates/.default/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 3class CookieNotify { 4 5 popUpDefaultParams = { 6 title: BX.message('MAIN_USER_CONSENT_REQUEST_TITLE'), 7 html: `<p class="cookiesnotify__main-text">${BX.message('MAIN_USER_CONSENT_REQUEST_PREVIEW_TEXT')}</p>`, 8 showCancelButton: false, 9 showCloseButton: false, 10 confirmButtonText: BX.message('MAIN_USER_CONSENT_REQUEST_BTN_ACCEPT'), 11 cancelButtonText: BX.message('MAIN_USER_CONSENT_REQUEST_BTN_REJECT'), 12 buttonsStyling: false, 13 width: false, 14 position: 'bottom-end', 15 backdrop: false, 16 allowOutsideClick: false, 17 allowEscapeKey: false, 18 timerProgressBar: false, 19 showClass: { 20 popup: ` 21 animate__animated 22 ${this.isTablet() ? 'animate__fadeInUp' : 'animate__fadeInRight'} 23 animate__faster 24 ` 25 }, 26 hideClass: { 27 popup: ` 28 animate__animated 29 ${this.isTablet() ? 'animate__fadeOutDown' : 'animate__fadeOutRight'} 30 animate__faster 31 ` 32 }, 33 fixBodyScroll: false, 34 customClass: { 35 container: 'cookiesnotify', 36 popup: 'cookiesnotify__popup', 37 title: 'cookiesnotify__title', 38 htmlContainer: 'cookiesnotify__content', 39 actions: 'cookiesnotify__actions', 40 confirmButton: 'cookiesnotify__btn cookiesnotify__btn-confirm', 41 cancelButton: 'cookiesnotify__btn cookiesnotify__btn-cancel', 42 closeButton: ' cookiesnotify__btn-close', 43 }, 44 } 45 46 constructor(params) { 47 this.params = params || null; 48 49 if (typeof this.params?.MAIN_TEXT !== "undefined" && this.params?.MAIN_TEXT !== null) { 50 this.popUpDefaultParams.html = `<p class="cookiesnotify__main-text">${this.params.MAIN_TEXT}</p>`; 51 } 52 53 if (typeof this.params?.TITLE_TEXT !== "undefined" && this.params?.TITLE_TEXT !== null) { 54 this.popUpDefaultParams.title = `${this.params.TITLE_TEXT}`; 55 } 56 57 if (this.params?.OVERLAY_ACTIVE === "Y") { 58 this.popUpDefaultParams.backdrop = true; 59 } 60 61 if (!!this.params?.LINK) { 62 let link_text = ''; 63 64 if (typeof this.params?.LINK_TEXT !== "undefined" && this.params?.LINK_TEXT !== null) { 65 link_text = `${this.params.LINK_TEXT}`; 66 } 67 68 this.popUpDefaultParams.html += `<a tabindex="0" class="cookiesnotify__agreement-link" href="${this.params.LINK}" target="_blank">${link_text}</a>` 69 70 71 if (this.params.DISABLE_OVERLAY_ON_LINK === 'Y') { 72 this.popUpDefaultParams.backdrop = false; 73 } 74 } 75 76 this.init(); 77 } 78 79 init() { 80 this.showCookieNotification(this.popUpDefaultParams).then(async results => { 81 const result = await results[0]; 82 if (result.isConfirmed) { 83 this.accept(); 84 } 85 }); 86 } 87 88 async showCookieNotification(options) { 89 await BX.loadExt('s34web.cookiesnotify.sweetalert2'); 90 BX.closeWait(); 91 92 if (!window.Swal) { 93 throw new Error('SweetAlert2 extension is not loaded!'); 94 } 95 96 const centerTitle = options.centerTitle === true; 97 const fixBodyScroll = options.fixBodyScroll !== false; 98 delete options.centerTitle; 99 delete options.fixBodyScroll; 100 101 const popupOptions = { 102 showCloseButton: false, 103 width: '464px', 104 showClass: { 105 popup: ` 106 animate__animated 107 animate__fadeIn 108 animate__faster 109 ` 110 }, 111 hideClass: { 112 popup: ` 113 animate__animated 114 animate__fadeOut 115 animate__faster 116 ` 117 }, 118 heightAuto: false, 119 scrollbarPadding: false, 120 focusConfirm: false, 121 confirmButtonText: BX.message('SWEETALERT2_CONFIRM_BUTTON_TEXT'), 122 denyButtonText: BX.message('SWEETALERT2_DENY_BUTTON_TEXT'), 123 cancelButtonText: BX.message('SWEETALERT2_CANCEL_BUTTON_TEXT'), 124 closeButtonAriaLabel: BX.message('SWEETALERT2_CLOSE_BUTTON_ARIA_LABEL'), 125 ...options, 126 didOpen: (popup) => { 127 if (fixBodyScroll) { 128 this.fixBodyScroll(); 129 } 130 options.didOpen && options.didOpen(popup); 131 }, 132 didDestroy: () => { 133 if (fixBodyScroll) { 134 this.unfixBodyScroll(); 135 } 136 137 options.didDestroy && options.didDestroy(); 138 }, 139 }; 140 141 /** @var {MixinSwal} popup */ 142 const popup = Swal.mixin(popupOptions); 143 144 return [popup.fire(), popup]; 145 } 146 147 isDesktop() { 148 return window.matchMedia('(min-width: 1440px)').matches; 149 } 150 151 isLaptop() { 152 return window.matchMedia('(max-width: 1024px)').matches; 153 } 154 155 isTablet() { 156 return window.matchMedia('(max-width: 768px)').matches; 157 } 158 159 isMobile() { 160 return window.matchMedia('(max-width: 576px)').matches; 161 } 162 163 accept() { 164 const date = new Date(); 165 let cookie_prefix = this.params.COOKIE_PREFIX ?? ''; 166 if (cookie_prefix !== '') { 167 cookie_prefix += '_'; 168 } 169 const cookie_name = cookie_prefix + 'USERCONSENT_COOKIES'; 170 171 date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000)); // Set the cookie expiration date to 7 days 172 173 BX.ajax.runAction(
174 's34web:cookiesnotify.UserConsent.saveconsent', 175 { 176 data: { 177 'url': window.location.href, 178 'agreement_id': this.params?.AGREEMENT?.ID ?? 0 179 } 180 } 181 ).then((response) => { 182 if (response.status === 'success') { 183 BX.setCookie(cookie_name, 'all', {path: '/', expires: date.toGMTString()}); 184 } 185 }).catch((response) => { 186 BX.setCookie(cookie_name, 'all', {path: '/', expires: date.toGMTString()}); 187 }); 188 } 189} 190/* End */ 191;; /* /bitrix/components/s34web/cookiesnotify/templates/.default/script.js?17775385766229*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.