4001if (window.history.state.productData) {4002var productPopupData = window.history.state.productData;4003var recidFromHistory = productPopupData.recid,4004optsFromHistory = productPopupData.opts,4005productObjFromHistory = productPopupData.productObj,4006isRelevantsShowFromHistory = productPopupData.isRelevantsShow;4007t_store_openProductPopup(4008recidFromHistory,4009optsFromHistory,4010productObjFromHistory,4011isRelevantsShowFromHistory,
true ); } else { t_store_closePopup(true, recid, opts); } } else { t_store_closePopup(true, recid, opts); } };}/** * Enables lazy loading of images in a product popup when the user scrolls the popup. * * @param {string} recid - The ID of the product whose popup to enable lazy loading in. */function t_store_popup_updLazyOnScroll(recid) { // need to update lazy on scroll in popup var scrollContainer = document.querySelector('#rec' + recid + ' .t-popup'); var curMode = document.getElementById('allrecords').getAttribute('data-tilda-mode'); if (scrollContainer && curMode !== 'edit' && curMode !== 'preview') { t_onFuncLoad('t_throttle', function () { scrollContainer.addEventListener( 'scroll', t_throttle(function () { t_store_onFuncLoad('t_lazyload_update', function () { t_lazyload_update(); }); }) ); }); }}/** * Updates the URL and browser history to reflect the currently open product popup. * * @param {string} recid - The ID of the product whose popup is open. * @param {Object} product - An object containing data for the product whose popup is open. * @param {boolean} isRelevantsShow - Whether the product popup is showing relevant products. * @param {TildaStoreOptions} options - An object containing options for the product popup. */function t_store_changeUrl(recid, product, isRelevantsShow, options) { var isiOS = /iPhone|iPad|iPod/i.test(navigator.userAgent); var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); var curUrl = window.location.href; var productData = { productObj: product, opts: options, isRelevantsShow: isRelevantsShow, recid: recid, }; var newUrl; var newPageTitle = document.title + ' – ' + product.title; if (curUrl.indexOf('/tproduct/') < 0 && curUrl.indexOf('%2Ftproduct%2F') < 0) { newUrl = t_store_generateUrl(product); t_store_history_pushState( { productData: productData, }, newPageTitle, newUrl ); if (isiOS && isSafari) { document.querySelector('head link[rel="canonical"]').setAttribute('href', newUrl); document.title = newPageTitle; } } else if (isRelevantsShow) { // for relevants newUrl = t_store_generateUrl(product); t_store_history_pushState( { productData: productData, }, newPageTitle, newUrl ); }}/** * Generates a URL for the given product based on its relative path. * * @param {Object} product - An object containing data for the product to generate a URL for. * @param {string} product.url - The URL of the product. * @return {string} - The generated URL for the product. */