1// AQ modal 2var aq_popup = {} 3 4aq_popup.loader = { 5 ready: function (fn) { 6 if (document.readyState == 'complete') { 7 return fn() 8 } 9 10 if (window.addEventListener) { 11 window.addEventListener('load', fn, false) 12 } else if (window.attachEvent) { 13 window.attachEvent('onload', fn) 14 } else { 15 window.onload = fn 16 } 17 }, 18} 19 20aq_popup.loader.ready(function () { 21 // Nette ajax call 22 $.nette.ext('popup-functions', { 23 before: function (xhr, settings) { 24 // Trigger element must be null before start of every function 25 if (this.trigger != null) this.trigger = null 26 // Define trigger element 27 if (settings.nette && settings.nette.el) 28 this.trigger = settings.nette.el 29 30 // Set ajax call variable only once for comparisons 31 if (this.trigger) { 32 aCall = this.trigger[0].dataset.ajaxCall 33 } else { 34 aCall = '' 35 } 36 37 // After Click 38 if (aCall == 'js-open-popup') { 39 // document.getElementById('ajax-spinner').style.display = 'block' 40 } 41 }, 42 43 complete: function () { 44 // Set ajax call variable only once for comparisons 45 if (this.trigger) { 46 aCall = this.trigger[0].dataset.ajaxCall 47 } else { 48 aCall = '' 49 } 50 51 // After Click open popup 52 if (aCall == 'js-open-popup') { 53 // Hide spinner 54 //document.getElementById('ajax-spinner').style.display = 'none' 55 console.log('popup open') 56 57 redirectPopup() 58 } else { 59 var addonAfterRegistration = document.getElementsByClassName( 60 'aq-popup-form--addonAfterRegistration' 61 ) 62 if (addonAfterRegistration.length) { 63 console.log('After registration Addon popup init') 64 } 65 } 66 }, 67 }) 68 69 // EXIT POPUP 70 var showExitInThisPage = document.getElementById('main').dataset.exitPopup 71 var showExit = true 72 var exitPopC = readCookie('exitPop') 73 74 if (showExitInThisPage == 'true' && showExit == true && exitPopC == null) { 75 console.log('Exit - ON') 76 77 // Add Spinner to body 78 var spinner = document.createElement('div') 79 spinner.setAttribute('id', 'ajax-spinner') 80 document.body.appendChild(spinner) 81 82 $(document).mouseleave(function () { 83 showExit = false 84 createCookie('exitPop', 'hide', 1) 85 86 var url = $('#main').data('ajax-popup') 87 88 if (url) { 89 // SHOW Spinner 90 document.getElementById('ajax-spinner').style.display = 'block' 91 92 $.nette.ajax({ 93 url: url, 94 complete: function () { 95 // Hide spinner 96 document.getElementById('ajax-spinner').style.display = 97 'none' 98 99 // Unbind mouseleave 100 $(document).unbind('mouseleave') 101 }, 102 }) 103 } else { 104 $('.aq-popup-bg').removeClass('js-hide').addClass('js-visible') 105 106 // Unbind mouseleave 107 $(document).unbind('mouseleave') 108 } 109 }) 110 } else { 111 console.log('Exit - OFF') 112 } 113 // EXIT popup open - END 114 115 // SHOP BONUS POPUP (#14499) - nabidka bonusu neprihlasenemu na detailu obchodu. 116 // Otevira se sama: 20 s na strance, nebo odscrollovani za polovinu dokumentu - co prijde driv. 117 // Server (ShopBonusPopupResolver) je autorita; cookie se tady cte jen proto, aby se zbytecne 118 // nestrilel AJAX na nekoho, kdo popup uz videl. 119 var bonusPopupTrigger = document.querySelector('[data-bonus-popup]') 120 121 if (bonusPopupTrigger && readCookie('shop-bonus-popup') == null) { 122 var bonusPopupDelay = 20000 123 var bonusPopupScrollRatio = 0.5 124 var bonusPopupFired = false 125 var bonusPopupTimer = null 126 127 var fireBonusPopup = function () { 128 if (bonusPopupFired) return 129 bonusPopupFired = true 130 131 clearTimeout(bonusPopupTimer) 132 window.removeEventListener('scroll', onBonusPopupScroll) 133 134 // Krok 1 popupu pri presmerovani je hlavni registracni cesta - nesmime ji prekryt. 135 if (document.querySelector('.aq-popup-bg.js-visible')) return 136 137 // Exit popup by jinak dorazil se skoro stejnou nabidkou v jedne navsteve. Nastavujeme 138 // jeho vlastni cookie, kterou uz dnes respektuje, takze jeho logika zustava nedotcena. 139 createCookie('exitPop', 'hide', 1) 140 141 $.nette.ajax({ url: bonusPopupTrigger.dataset.bonusPopup }) 142 } 143 144 var onBonusPopupScroll = function () { 145 var scrollable = document.documentElement.scrollHeight - window.innerHeight 146 147 if (scrollable > 0 && window.pageYOffset / scrollable >= bonusPopupScrollRatio) { 148 fireBonusPopup() 149 } 150 } 151
152 bonusPopupTimer = setTimeout(fireBonusPopup, bonusPopupDelay) 153 window.addEventListener('scroll', onBonusPopupScroll, { passive: true }) 154 } 155 156 // Zavreni: krizek, klik na pozadi i Esc. Vsechny cesty voli signal close!, aby se popup_close 157 // logoval serverem stejne jako u ostatnich popupu. 158 function closeShopBonusPopup(popup) { 159 var closeUrl = popup.dataset.closeUrl 160 popup.remove() 161 162 if (closeUrl) { 163 $.nette.ajax({ url: closeUrl }) 164 } 165 } 166 167 document.addEventListener('click', function (event) { 168 var popup = document.getElementById('shop-bonus-popup') 169 170 if (!popup) return 171 172 if (event.target.closest('.shop-bonus-popup__close') || !event.target.closest('.shop-bonus-popup__panel')) { 173 closeShopBonusPopup(popup) 174 } 175 }) 176 177 document.addEventListener('keydown', function (event) { 178 var popup = document.getElementById('shop-bonus-popup') 179 180 if (popup && event.key === 'Escape') { 181 closeShopBonusPopup(popup) 182 } 183 }) 184 // SHOP BONUS POPUP - END 185 186 // REDIRECT popup open - START 187 function redirectPopup() { 188 console.log('redirect popup') 189 $('a[data-redirect-popup]').unbind() 190 191 $('a[data-redirect-popup]').on('click tap', function () { 192 // Add Spinner to body 193 var spinner = document.createElement('div') 194 spinner.setAttribute('id', 'ajax-spinner') 195 document.body.appendChild(spinner) 196 197 // SHOW Spinner 198 document.getElementById('ajax-spinner').style.display = 'block' 199 200 var url = $('a[data-redirect-popup]').data('redirect-popup') 201 202 $.nette.ajax({ 203 url: url, 204 complete: function () { 205 // Hide spinner 206 document.getElementById('ajax-spinner').style.display = 207 'none' 208 }, 209 }) 210 }) 211 } 212 213 redirectPopup() 214 215 function createCookie(name, value, days) { 216 var expires 217 218 if (days) { 219 var date = new Date() 220 date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000) 221 expires = '; expires=' + date.toGMTString() 222 } else { 223 expires = '' 224 } 225 document.cookie = 226 encodeURIComponent(name) + 227 '=' + 228 encodeURIComponent(value) + 229 expires + 230 '; path=/' 231 } 232 233 function readCookie(name) { 234 var nameEQ = encodeURIComponent(name) + '=' 235 var ca = document.cookie.split(';') 236 for (var i = 0; i < ca.length; i++) { 237 var c = ca[i] 238 while (c.charAt(0) === ' ') c = c.substring(1, c.length) 239 if (c.indexOf(nameEQ) === 0) 240 return decodeURIComponent(c.substring(nameEQ.length, c.length)) 241 } 242 return null 243 } 244 245 function eraseCookie(name) { 246 createCookie(name, '', -1) 247 } 248})
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.