1var REVO_GLOBALS = { 2 'DEFAULT_BUY_BTN_CLASS': 'product-item-detail-buy-button', 3 'DEFAULT_CHECKOUT_BTN_CLASS': 'basket-btn-checkout', 4 'DEFAULT_DETAIL_PRICE_CLASS': 'product-item-detail-price-current', 5 'DEFAULT_CART_PRICE_CLASS': 'basket-coupon-block-total-price-current', 6}; 7 8function revoModal() { 9 return document.getElementById('revo-modal-window'); 10} 11 12function tryToClickAddCart() { 13 return; 14 15 var node = false; 16 if (window.buyBtnSelector) { 17 if (window.buyBtnSelector[0] === '.') { 18 var className = window.buyBtnSelector.replace('.', ''); 19 node = document.getElementsByClassName(className)[0]; 20 } 21 if (window.buyBtnSelector[0] === '#') { 22 var idName = window.buyBtnSelector.replace('#', ''); 23 node = document.getElementById(idName); 24 } 25 } else { 26 node = document.getElementsByClassName(REVO_GLOBALS.DEFAULT_BUY_BTN_CLASS)[0] || 27 document.getElementsByClassName(REVO_GLOBALS.DEFAULT_CHECKOUT_BTN_CLASS)[0]; 28 } 29 30 node && node.click(); 31} 32var moduleID; 33var existModuleID = false; 34function getModuleID() { 35 if(existModuleID == false) { 36 $.ajax({
37 type: 'POST', 38 url: '/local/components/revo/config/config.php', 39 data: 'getModuleID', 40 async: false, 41 success: function(data){ 42 moduleID = JSON.parse(data); 43 // console.log('getModuleId called: '+moduleID); 44 } 45 }); 46 existModuleID = true; 47 } 48} 49 50function revoShowModal(fastBuyMode, orderModeUrl, display) { 51 let successCallback = function(data) { 52 if (data.message === 'declined') { 53 alert('Ðам оÑказано в кÑедиÑном лимиÑе.'); 54 return false; 55 } else if (data.url && !orderModeUrl) { 56 REVO.Form.show(data.url, '#revo-iframe-container'); 57 58 revoModal().style.display = 'block'; 59 window.revoSent = false; 60 // window.ORDER_MODE_URL = orderModeUrl; 61 } else { 62 if (fastBuyMode) { 63 tryToClickAddCart(); 64 } 65 66 if (orderModeUrl) { 67 REVO.Form.show(orderModeUrl, '#revo-iframe-container'); 68 69 revoModal().style.display = display; 70 window.ORDER_MODE = true; 71 } 72 } 73 }; 74 75 let failureCallback = function () { 76 alert('Server error. Please check the settings.'); 77 }; 78 79 let data = { 80 'action': 'register' 81 }; 82 83 getModuleID(); 84 // console.log('moduleId: '+moduleID); 85 86 BX.ajax({ 87 timeout: 120, 88 method: 'POST', 89 dataType: 'json', 90 url: '/ajax/'+moduleID+'/ajax.php', 91 data: data, 92 onsuccess: successCallback, 93 onfailure: failureCallback 94 }); 95} 96 97var askBtnPressed = false; 98 99BX.ready(function() { 100 var INSTALMENT_PERIOD = 12; 101 if (window.revoLoaded) return; 102 window.revoLoaded = true; 103 104 setTimeout(function () {updatePrice();}, 1000); 105 106 $('.price-module__modal-trigger').on('click', function() { 107 askBtnPressed = true; 108 }); 109 110 BX.bindDelegate( 111 document.body, 'click', {className: 'js-rvo-buy-link' }, 112 function(e){ 113 if(!e) { 114 e = window.event; 115 } 116 window.productDetailMode = true; 117 window.buyBtnSelector = this.dataset.buybtn; 118 if(askBtnPressed == false) { 119 revoShowModal(true); 120 } 121 return BX.PreventDefault(e); 122 } 123 ); 124 125 if (REVO && REVO.Form) { 126 REVO.Form.onClose(function() { 127 revoModal().style.display = 'none'; 128 if (window.revoCloseTrigger) { 129 window.revoCloseTrigger(); 130 } 131 }); 132 133 REVO.Form.onResult(function(result) { 134 if (window.ORDER_MODE_URL) { 135 REVO.Form.show(window.ORDER_MODE_URL, '#revo-iframe-container'); 136 window.ORDER_MODE_URL = false; 137 window.ORDER_MODE = true; 138 revoModal().style.display = 'block'; 139 } else { 140 window.revoCloseTrigger = function() { 141 if (REVO_ORDERS_URL) { 142 // location.href = REVO_ORDERS_URL; 143 } 144 } 145 } 146 }); 147 } 148 149 let clickBound = false; 150 151 setInterval(function () { 152 document.getElementsByName('PAY_SYSTEM_ID').forEach(function (a) { 153 if (parseInt(a.value) === parseInt(REVO_PAY_SYSTEM_ID)) { 154 if (REVO_REQUEST_DECLINED) { 155 a.disabled = 'disabled'; 156 } 157 if (!clickBound) { 158 clickBound = true; 159 160 BX.bindDelegate(document.body, 'click', {'callback': function(obj) { 161 let a = false; 162 for (let i in obj.childNodes) { 163 if (obj.childNodes[i].id === 'ID_PAY_SYSTEM_ID_'+REVO_PAY_SYSTEM_ID) { 164 a = true; 165 } 166 } 167 return a; 168 }}, function () { 169 if (REVO_REQUEST_DECLINED) { 170 alert('Ðам оÑказано в кÑедиÑном лимиÑе.'); 171 return; 172 } 173 if (window.revoSent) return; 174 window.revoSent = true; 175 console.log("show Modal on Change");
176 //revoShowModal(); 177 }); 178 } 179 } 180 }); 181 }, 1000); 182 183 getModuleID(); 184 // console.log('moduleId 2: '+moduleID); 185 BX.ajax({ 186 method: 'GET', 187 dataType: 'html', 188 url: '/bitrix/html/'+moduleID+'/modal.template.html', 189 /* 190 бÑл ÑлÑÑай когда паÑÑÐ½ÐµÑ Ð² Ñаблоне sale.order.ajax в Ñайле script.js подпиÑÑвалÑÑ Ð½Ð° ÑобÑÑие onAjaxSuccess 191 BX.addCustomEvent('onAjaxSuccess', function () {*some code*} 192 script.js оÑÑабаÑÑÐ²Ð°ÐµÑ Ð¸ на ÑÑапе ввода ÑеквизиÑов и на ÑÑапе подÑвеÑÐ¶Ð´ÐµÐ½Ð¸Ñ Ð¿Ð»Ð°Ñежа (ÑÑÑ Ñ Ð½Ð°Ñ Ð¾ÑкÑÑваеÑÑÑ Ð¼Ð¾Ð´Ð°Ð»ÐºÐ°) 193 и Ð²Ð¾Ñ Ð½Ð° ÑÑапе подÑвеÑÐ¶Ð´ÐµÐ½Ð¸Ñ Ð¿Ð»Ð°Ñежа Ñ Ð½Ð¸Ñ Ð² коде возникала оÑибка, из-за Ñего Ð½Ð°Ñ ÐºÐ¾Ð´ Ñоже ломалÑÑ. 194 на пÑакÑике вÑглÑдело Ñак: 195 вÑÑÐºÐ°ÐºÐ¸Ð²Ð°ÐµÑ Ð¿Ð»Ð°Ñка "Server error.." -> жмем ÐÐ -> оÑкÑÑваеÑÑÑ Ð½Ð°Ñа модалка 196 */ 197 onsuccess: function (data) { 198 var doc = new DOMParser().parseFromString(data, "text/html"); 199 BX.append(doc.body.firstChild, document.body); 200 201 // закÑÑÑÑ iFrame по нажаÑÐ¸Ñ Ð½Ð° пÑÑÑÑÑ Ð¾Ð±Ð»Ð°ÑÑÑ Ð²Ð½Ðµ iFrame 202 // BX.bind(document.getElementById('revo-modal-window'), 'click', function () { 203 // this.style.display = 'none' ; 204 // }); 205 206 var event = new Event('revo_modal_ready'); 207 document.dispatchEvent(event); 208 // console.log('Second ajax is called'); 209 } 210 }); 211 console.log() 212 213 function updatePrice() { 214 if (REVO_ADD_PRICE_BLOCK > 0) { 215 var priceEl = document.getElementsByClassName(REVO_GLOBALS.DEFAULT_DETAIL_PRICE_CLASS)[0] 216 || document.getElementsByClassName(REVO_GLOBALS.DEFAULT_CART_PRICE_CLASS)[0]; 217 218 if (priceEl) { 219 var price = parseFloat(priceEl.innerText.replace(/[^0-9]/, '')); 220 221 var btnEl = document.getElementsByClassName(REVO_GLOBALS.DEFAULT_BUY_BTN_CLASS)[0] || 222 document.getElementsByClassName(REVO_GLOBALS.DEFAULT_CHECKOUT_BTN_CLASS)[0]; 223 224 if (btnEl && price >= REVO_MIN_PRICE && (REVO_MAX_PRICE > 0 && price <= REVO_MAX_PRICE)) { 225 var priceMonthly = Math.round(price / INSTALMENT_PERIOD); 226 var link = document.createElement('a'); 227 228 link.innerHTML = BX.message('REVO_BUY_DETAIL').replace('#PRICE#', priceMonthly); 229 link.href = '#'; 230 link.className = 'js-rvo-buy-link rvo-buy-link'; 231 btnEl 232 .parentElement 233 .appendChild(link); 234 } 235 } 236 } 237 } 238 239 BX.addCustomEvent('OnBasketChange', function () { 240 setTimeout(function () {updatePrice();}, 1000); 241 }); 242});
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.