1(function($){ 2 if(document.body){ document.body.classList.add('wegene-wcx-active'); if(window.wegeneWCX&&wegeneWCX.pageType){document.body.classList.add('wcx-page-'+wegeneWCX.pageType);} if(window.matchMedia&&window.matchMedia('(max-width: 767px)').matches){document.body.classList.add('wcx-mobile');} } 3 function openCart(){$('#wcx-cart-drawer').addClass('is-open').attr('aria-hidden','false');$('.wcx-drawer-backdrop').prop('hidden',false);$('body').css('overflow','hidden');} 4 function closeCart(){$('#wcx-cart-drawer').removeClass('is-open').attr('aria-hidden','true');$('.wcx-drawer-backdrop').prop('hidden',true);$('body').css('overflow','');} 5 $(document).on('click','.wcx-open-cart',function(e){e.preventDefault();openCart();}); 6 $(document).on('click','.wcx-close-cart,.wcx-drawer-backdrop',closeCart); 7 $(document).on('keydown',function(e){if(e.key==='Escape')closeCart();}); 8 $(document.body).on('added_to_cart',function(){openCart();logEvent('interaction',{eventName:'added_to_cart'});}); 9 function normalizeProductPage(){ 10 if(!window.wegeneWCX||wegeneWCX.pageType!=='product')return; 11 document.body.classList.add('wcx-page-product'); 12 var product=document.querySelector('div.product.type-product, div.product'); 13 if(!product)return; 14 product.classList.add('wcx-product-layout'); 15 16 // The Wegene theme places the WooCommerce product inside a Bootstrap row 17 // with a content column and a reserved sidebar column. Identify the actual 18 // column carrying the product, expand it to 100%, and suppress only its 19 // sibling columns on single-product pages. 20 var themeRow=product.closest('.row'); 21 if(themeRow){ 22 themeRow.classList.add('wcx-product-theme-row'); 23 var carrier=product; 24 while(carrier.parentElement && carrier.parentElement!==themeRow){carrier=carrier.parentElement;} 25 if(carrier && carrier.parentElement===themeRow){ 26 carrier.classList.add('wcx-product-theme-column'); 27 Array.prototype.forEach.call(themeRow.children,function(child){ 28 if(child!==carrier){child.classList.add('wcx-product-theme-unused-column');} 29 }); 30 } 31 var themeContainer=themeRow.parentElement; 32 if(themeContainer)themeContainer.classList.add('wcx-product-theme-container'); 33 var themeSection=themeRow.closest('section'); 34 if(themeSection)themeSection.classList.add('wcx-product-theme-section'); 35 } 36 var wrap=product.closest('.wrap'); 37 if(wrap)wrap.classList.add('wcx-product-theme-wrap'); 38 39 var gallery=product.querySelector('.woocommerce-product-gallery, .images'); 40 var summary=product.querySelector('.summary, .entry-summary'); 41 if(gallery)gallery.classList.add('wcx-product-gallery'); 42 if(!summary){ 43 summary=document.createElement('div'); 44 summary.className='summary entry-summary wcx-product-summary'; 45 product.appendChild(summary); 46 }else{summary.classList.add('wcx-product-summary');} 47 48 var title=summary.querySelector('.product_title'); 49 if(!title){ 50 var candidates=document.querySelectorAll('h1.product_title, h1.entry-title, .product_title'); 51 Array.prototype.some.call(candidates,function(node){ 52 if(node!==summary && !summary.contains(node) && (node.textContent||'').trim()){ 53 title=node;return true; 54 } 55 return false; 56 }); 57 } 58 if(title&&!summary.contains(title)){ 59 var clone=title.cloneNode(true); 60 clone.classList.add('product_title'); 61 summary.insertBefore(clone,summary.firstChild); 62 title.classList.add('wcx-original-product-title'); 63 title.setAttribute('aria-hidden','true'); 64 } 65 66 if(summary.querySelector('form.cart')){ 67 Array.prototype.forEach.call(product.querySelectorAll('a[href]'),function(link){ 68 var href=(link.getAttribute('href')||'').toLowerCase(),text=(link.textContent||'').trim().toLowerCase(); 69 if(href.indexOf('givebutter.com')!==-1||href.indexOf('paypal.me')!==-1||text==='buy'||text==='buy now'){ 70 if(!link.classList.contains('wcx-open-cart')){link.classList.add('wcx-hidden-competing-cta');link.setAttribute('aria-hidden','true');link.setAttribute('tabindex','-1');} 71 } 72 }); 73 } 74 75 76 Array.prototype.forEach.call(product.querySelectorAll('a,button,input[type=button],input[type=submit]'),function(control){ 77 var text=((control.textContent||control.value||'').trim()).toLowerCase(); 78 var href=(control.getAttribute&&control.getAttribute('href')||'').toLowerCase(); 79 if((text==='buy'||text==='buy now'||href.indexOf('givebutter.com')!==-1) && !control.closest('form.cart') && !control.classList.contains('wcx-open-cart')){ 80 control.classList.add('wcx-hidden-competing-cta'); 81 control.setAttribute('aria-hidden','true'); 82 control.setAttribute('tabindex','-1'); 83 } 84 }); 85 // Keep narrative, tabs, and recommendations out of the purchase column. 86 Array.prototype.forEach.call(product.children,function(child){ 87 if(child!==gallery && child!==summary){child.classList.add('wcx-product-lower-section');} 88 }); 89 } 90 normalizeProductPage();window.addEventListener('load',normalizeProductPage,{once:true}); 91 92 function stabilizeProductGallery(){ 93 if(!window.wegeneWCX||wegeneWCX.pageType!=='product')return; 94 // Use one deterministic gallery on every viewport. This avoids FlexSlider 95 // active-slide width/height mutations and keeps every image fully visible. 96 var gallery=document.querySelector('.wcx-product-gallery,.woocommerce-product-gallery'); 97 if(!gallery||gallery.dataset.wcxGalleryReady==='1')return; 98 99 var slides=Array.prototype.slice.call(gallery.querySelectorAll('.woocommerce-product-gallery__image')); 100 var images=[];
101 slides.forEach(function(slide,index){ 102 var img=slide.querySelector('img'); 103 if(!img)return; 104 var link=slide.querySelector('a'); 105 var full=img.getAttribute('data-large_image')||img.getAttribute('data-src')||(link&&link.getAttribute('href'))||img.currentSrc||img.src; 106 var thumb=img.getAttribute('data-src')||img.currentSrc||img.src||full; 107 if(!full)return; 108 images.push({full:full,thumb:thumb,alt:img.getAttribute('alt')||'',srcset:img.getAttribute('data-large_image_srcset')||''}); 109 }); 110 if(!images.length)return; 111 112 gallery.dataset.wcxGalleryReady='1'; 113 gallery.classList.add('wcx-gallery-custom'); 114 115 var shell=document.createElement('div'); 116 shell.className='wcx-gallery-shell'; 117 var stage=document.createElement('a'); 118 stage.className='wcx-gallery-stage'; 119 stage.href=images[0].full; 120 stage.setAttribute('aria-label','Open product image'); 121 var stageImg=document.createElement('img'); 122 stageImg.className='wcx-gallery-stage-image'; 123 stageImg.src=images[0].full; 124 stageImg.alt=images[0].alt; 125 stage.appendChild(stageImg); 126
127 var rail=document.createElement('div'); 128 rail.className='wcx-gallery-rail'; 129 rail.setAttribute('role','list'); 130 131 function activate(index){ 132 var item=images[index]; 133 if(!item)return; 134 stageImg.removeAttribute('srcset'); 135 stageImg.removeAttribute('sizes'); 136 stageImg.src=item.full; 137 stageImg.alt=item.alt; 138 stage.href=item.full; 139 Array.prototype.forEach.call(rail.querySelectorAll('.wcx-gallery-thumb'),function(button,i){ 140 var active=i===index; 141 button.classList.toggle('is-active',active); 142 button.setAttribute('aria-current',active?'true':'false'); 143 }); 144 } 145 146 images.forEach(function(item,index){ 147 var button=document.createElement('button'); 148 button.type='button'; 149 button.className='wcx-gallery-thumb'+(index===0?' is-active':''); 150 button.setAttribute('role','listitem'); 151 button.setAttribute('aria-label','Show product image '+(index+1)); 152 button.setAttribute('aria-current',index===0?'true':'false'); 153 var image=document.createElement('img'); 154 image.src=item.thumb; 155 image.alt=''; 156 button.appendChild(image); 157 button.addEventListener('click',function(event){event.preventDefault();activate(index);}); 158 rail.appendChild(button); 159 }); 160 161 shell.appendChild(stage); 162 if(images.length>1)shell.appendChild(rail); 163 gallery.insertBefore(shell,gallery.firstChild); 164 activate(0); 165 } 166 stabilizeProductGallery();window.addEventListener('load',stabilizeProductGallery,{once:true}); 167 168 function buildEditorialProductDetails(){ 169 if(!window.wegeneWCX||wegeneWCX.pageType!=='product')return; 170 var product=document.querySelector('div.product.type-product,div.product'); 171 var summary=product&&product.querySelector('.wcx-product-summary,.summary.entry-summary,.summary'); 172 if(!product||!summary||summary.querySelector('.wcx-editorial-details'))return; 173 174 var details=document.createElement('div'); 175 details.className='wcx-editorial-details'; 176 177 function addRow(label,source,open){ 178 if(!source)return; 179 var clone=source.cloneNode(true); 180 Array.prototype.forEach.call(clone.querySelectorAll('h2,.tabs,.button,a.button,a.btn--secondary,.wcx-hidden-competing-cta'),function(el){el.remove();}); 181 var text=(clone.textContent||'').replace(/\s+/g,' ').trim(); 182 if(!text)return; 183 var row=document.createElement('details'); 184 row.className='wcx-editorial-detail'; 185 if(open)row.open=true; 186 var head=document.createElement('summary'); 187 head.innerHTML='<span>'+label+'</span><span class="wcx-editorial-detail__icon" aria-hidden="true">+</span>'; 188 var body=document.createElement('div'); 189 body.className='wcx-editorial-detail__body'; 190 while(clone.firstChild)body.appendChild(clone.firstChild); 191 row.appendChild(head);row.appendChild(body);details.appendChild(row); 192 } 193 194 var desc=product.querySelector('.woocommerce-Tabs-panel--description,.woocommerce-tabs .panel'); 195 var story=product.querySelector('.wcx-story-panel'); 196 addRow('Product details',desc,true); 197 addRow('The story behind this piece',story,false); 198 199 var meta=summary.querySelector('.product_meta'); 200 if(meta){ 201 var metaWrap=document.createElement('div'); 202 metaWrap.className='wcx-editorial-meta-row'; 203 metaWrap.innerHTML='<span>Collection</span><span>'+meta.innerHTML+'</span>'; 204 details.appendChild(metaWrap); 205 meta.classList.add('wcx-editorial-source-hidden'); 206 } 207 208 var anchor=summary.querySelector('form.cart'); 209 if(anchor&&anchor.parentNode){ 210 var paymentEnd=summary.querySelector('.ppc-button-wrapper,.wc-stripe-product-checkout-container,.apple-pay-button-wrapper,[class*="express-payment"]'); 211 if(paymentEnd&&paymentEnd.parentNode===summary)paymentEnd.insertAdjacentElement('afterend',details); 212 else anchor.insertAdjacentElement('afterend',details); 213 }else summary.appendChild(details); 214 215 if(desc)desc.closest('.woocommerce-tabs')&&desc.closest('.woocommerce-tabs').classList.add('wcx-editorial-source-hidden'); 216 if(story)story.classList.add('wcx-editorial-source-hidden'); 217 } 218 buildEditorialProductDetails();window.addEventListener('load',buildEditorialProductDetails,{once:true}); 219 220 function normalizeMobileProductEntry(){ 221 // v1.13.0: product-entry positioning is handled once, before paint, by the 222 // wp_head guard on the destination product page. Do not rewrite product 223 // links, preserve previous scroll positions, or schedule scroll corrections. 224 return; 225 } 226 normalizeMobileProductEntry(); 227 // Compatibility cleanup for stale cached pages from versions 1.13.6-1.13.8, 228 // which appended #wcx-product-top to product URLs. Remove it from all product 229 // anchors, including nodes injected later by WooCommerce, and intercept clicks 230 // so even stale cached markup cannot navigate with the legacy fragment. 231 function sanitizeProductHref(anchor){ 232 if(!anchor||!anchor.getAttribute)return; 233 var raw=anchor.getAttribute('href')||''; 234 if(!raw||raw.indexOf('#wcx-product-top')===-1)return; 235 anchor.setAttribute('href',raw.replace(/#wcx-product-top/g,'')); 236 } 237 function sanitizeAllProductLinks(root){ 238 root=root||document; 239 Array.prototype.forEach.call(root.querySelectorAll('a[href*="#wcx-product-top"]'),sanitizeProductHref); 240 } 241 sanitizeAllProductLinks(document); 242 if(window.MutationObserver){ 243 new MutationObserver(function(records){ 244 records.forEach(function(record){ 245 Array.prototype.forEach.call(record.addedNodes||[],function(node){ 246 if(!node||node.nodeType!==1)return; 247 if(node.matches&&node.matches('a[href*="#wcx-product-top"]'))sanitizeProductHref(node); 248 if(node.querySelectorAll)sanitizeAllProductLinks(node); 249 }); 250 }); 251 }).observe(document.documentElement,{childList:true,subtree:true}); 252 } 253 document.addEventListener('click',function(event){ 254 var link=event.target&&event.target.closest?event.target.closest('a[href]'):null; 255 if(!link)return; 256 var href=link.href||''; 257 if(!href)return; 258 try{ 259 var url=new URL(href,window.location.href); 260 if(url.origin===window.location.origin && /\/product\//.test(url.pathname)){ 261 if(url.hash==='#wcx-product-top')url.hash=''; 262 var clean=url.pathname+url.search; 263 // Only take over when the rendered href is stale or still has a fragment. 264 if(link.href!==url.href || (link.getAttribute('href')||'').indexOf('#wcx-product-top')!==-1){ 265 event.preventDefault(); 266 window.location.assign(clean); 267 } 268 } 269 }catch(e){} 270 },true); 271 function removeLegacyCommerceCtas(){ 272 if(!window.wegeneWCX||wegeneWCX.pageType!=='product')return; 273 var root=document.querySelector('main,#main,.site-main,.content-area')||document; 274 Array.prototype.forEach.call(root.querySelectorAll('a,button,input[type="button"],input[type="submit"]'),function(control){ 275 var text=((control.textContent||control.value||'').trim()).toLowerCase(); 276 var href=(control.getAttribute&&control.getAttribute('href')||'').toLowerCase(); 277 if((text==='buy'||text==='buy now'||href.indexOf('givebutter.com')!==-1) && !control.closest('form.cart') && !control.classList.contains('wcx-open-cart')){ 278 control.classList.add('wcx-hidden-competing-cta'); 279 control.setAttribute('aria-hidden','true'); 280 control.setAttribute('tabindex','-1'); 281 } 282 }); 283 } 284 removeLegacyCommerceCtas();window.addEventListener('load',removeLegacyCommerceCtas,{once:true}); 285 function normalizeShopPage(){ 286 if(!window.wegeneWCX||['shop','product-taxonomy'].indexOf(wegeneWCX.pageType)===-1)return; 287 document.body.classList.add('wcx-page-shop'); 288 var products=document.querySelector('ul.products'); 289 if(!products)return; 290 var themeRow=products.closest('.row'); 291 if(themeRow){ 292 themeRow.classList.add('wcx-shop-theme-row'); 293 var carrier=products; 294 while(carrier.parentElement&&carrier.parentElement!==themeRow){carrier=carrier.parentElement;} 295 if(carrier&&carrier.parentElement===themeRow){ 296 carrier.classList.add('wcx-shop-theme-column'); 297 Array.prototype.forEach.call(themeRow.children,function(child){ 298 if(child!==carrier){child.classList.add('wcx-shop-theme-unused-column');} 299 }); 300 } 301 if(themeRow.parentElement)themeRow.parentElement.classList.add('wcx-shop-theme-container'); 302 var section=themeRow.closest('section'); 303 if(section)section.classList.add('wcx-shop-theme-section'); 304 } 305 var wrap=products.closest('.wrap'); 306 if(wrap)wrap.classList.add('wcx-shop-theme-wrap'); 307 308 var filters=document.querySelector('.wcx-filter-shell'); 309 if(filters){ 310 var section=filters.closest('section'); 311 if(section){ 312 Array.prototype.forEach.call(section.querySelectorAll('h1,h2,p,hr'),function(node){ 313 if(node.closest('.wcx-filter-shell,.wcx-shopbar,li.product'))return; 314 var text=(node.textContent||'').trim().toLowerCase(); 315 if(text==='products'||(node.tagName==='P'&&node.compareDocumentPosition(filters)&Node.DOCUMENT_POSITION_FOLLOWING)||node.tagName==='HR'){ 316 node.classList.add('wcx-legacy-shop-intro'); 317 } 318 }); 319 } 320 } 321 } 322 normalizeShopPage();window.addEventListener('load',normalizeShopPage,{once:true}); 323 function markMobileCommerceCanvas(){ 324 if(!window.matchMedia||!window.matchMedia('(max-width: 767px)').matches)return;
325 var anchor=document.querySelector('.wcx-filter-shell, form.checkout, .woocommerce-cart-form, .wcx-product-layout, ul.products'); 326 if(!anchor)return; 327 var main=anchor.closest('main,#main,.site-main,.content-area'); 328 if(main)main.classList.add('wcx-mobile-commerce-root'); 329 var node=anchor.parentElement; 330 var limit=main||document.body; 331 while(node&&node!==limit&&node!==document.body){ 332 node.classList.add('wcx-mobile-commerce-chain'); 333 node=node.parentElement; 334 } 335 } 336 markMobileCommerceCanvas();window.addEventListener('load',markMobileCommerceCanvas,{once:true});window.addEventListener('resize',markMobileCommerceCanvas); 337 338 function cleanLegacyShopIntro(){ 339 var filters=document.querySelector('.wcx-filter-shell'); 340 if(!filters)return; 341 var selectors=['.entry-header','.page-header','.woocommerce-products-header','.page-title']; 342 selectors.forEach(function(selector){ 343 document.querySelectorAll(selector).forEach(function(node){ 344 if(!node.contains(filters) && !node.closest('.wcx-filter-shell') && (node.compareDocumentPosition(filters)&Node.DOCUMENT_POSITION_FOLLOWING)){ 345 node.classList.add('wcx-legacy-shop-intro'); 346 } 347 }); 348 }); 349 document.querySelectorAll('h1,h2,.page-title').forEach(function(heading){ 350 if((heading.textContent||'').trim().toLowerCase()!=='products')return; 351 if(heading.closest('.wcx-filter-shell,.wcx-shopbar,.wcx-shop-story'))return; 352 if(!(heading.compareDocumentPosition(filters)&Node.DOCUMENT_POSITION_FOLLOWING))return; 353 heading.classList.add('wcx-legacy-shop-intro'); 354 var next=heading.nextElementSibling; 355 var guard=0; 356 while(next && guard<4 && next!==filters && !next.contains(filters)){ 357 if(next.matches('p,hr,.separator,.divider'))next.classList.add('wcx-legacy-shop-intro'); 358 else break; 359 next=next.nextElementSibling;guard++; 360 } 361 var block=heading.parentElement; 362 if(block && !block.contains(filters) && block.children.length<=5){ 363 block.classList.add('wcx-legacy-shop-intro-block'); 364 } 365 }); 366 } 367 cleanLegacyShopIntro();window.addEventListener('load',cleanLegacyShopIntro,{once:true}); 368 369 function wcxRound(n){return Math.round((Number(n)||0)*100)/100;} 370 function wcxNodeLabel(el){ 371 if(!el||el.nodeType!==1)return ''; 372 var id=el.id?'#'+el.id:''; 373 var cls=Array.prototype.slice.call(el.classList||[],0,8).map(function(c){return '.'+c;}).join(''); 374 return (el.tagName||'').toLowerCase()+id+cls; 375 } 376 function wcxStyleSnapshot(el){ 377 if(!el||el.nodeType!==1)return null; 378 var r=el.getBoundingClientRect(),c=getComputedStyle(el); 379 return { 380 node:wcxNodeLabel(el),x:wcxRound(r.x),y:wcxRound(r.y),width:wcxRound(r.width),height:wcxRound(r.height), 381 display:c.display,position:c.position,float:c.cssFloat,boxSizing:c.boxSizing, 382 widthRule:c.width,minWidth:c.minWidth,maxWidth:c.maxWidth, 383 margin:[c.marginTop,c.marginRight,c.marginBottom,c.marginLeft].join(' '), 384 padding:[c.paddingTop,c.paddingRight,c.paddingBottom,c.paddingLeft].join(' '), 385 transform:c.transform,zoom:c.zoom||'',overflowX:c.overflowX,overflowY:c.overflowY, 386 gridTemplateColumns:c.gridTemplateColumns,gridColumn:c.gridColumn, 387 flex:c.flex,flexBasis:c.flexBasis,alignSelf:c.alignSelf, 388 left:c.left,right:c.right,contain:c.contain,contentVisibility:c.contentVisibility 389 }; 390 } 391 function wcxAncestorChain(el){ 392 var out=[],n=el,guard=0; 393 while(n&&n.nodeType===1&&guard<18){out.push(wcxStyleSnapshot(n));n=n.parentElement;guard++;} 394 return out; 395 } 396 function wcxFindAnchor(){ 397 var selectors=['.wcx-filter-shell','ul.products','.woocommerce-cart-form','form.checkout','.wcx-product-layout','.woocommerce']; 398 for(var i=0;i<selectors.length;i++){var el=document.querySelector(selectors[i]);if(el)return {selector:selectors[i],el:el};} 399 return {selector:'body',el:document.body}; 400 } 401 function buildDeepLayout(reason){ 402 var a=wcxFindAnchor(),r=a.el.getBoundingClientRect(); 403 return { 404 generatedAt:new Date().toISOString(),pluginVersion:(window.wegeneWCX&&wegeneWCX.pluginVersion)||'unknown',pageType:(window.wegeneWCX&&wegeneWCX.pageType)||'unknown', 405 reason:reason||'automatic',href:location.href,userAgent:navigator.userAgent, 406 viewport:{innerWidth:innerWidth,innerHeight:innerHeight,clientWidth:document.documentElement.clientWidth,clientHeight:document.documentElement.clientHeight,scrollWidth:document.documentElement.scrollWidth},
407 visualViewport:window.visualViewport?{width:wcxRound(visualViewport.width),height:wcxRound(visualViewport.height),scale:wcxRound(visualViewport.scale),offsetLeft:wcxRound(visualViewport.offsetLeft),offsetTop:wcxRound(visualViewport.offsetTop)}:null, 408 screen:{width:screen.width,height:screen.height,availWidth:screen.availWidth,availHeight:screen.availHeight,dpr:devicePixelRatio||1,orientation:(screen.orientation&&screen.orientation.type)||''}, 409 anchorSelector:a.selector,anchor:wcxStyleSnapshot(a.el),ancestors:wcxAncestorChain(a.el), 410 html:wcxStyleSnapshot(document.documentElement),body:wcxStyleSnapshot(document.body), 411 keyElements:{filter:wcxStyleSnapshot(document.querySelector('.wcx-filter-shell')),products:wcxStyleSnapshot(document.querySelector('ul.products')),results:wcxStyleSnapshot(document.querySelector('.wcx-results-bar,.woocommerce-result-count')),main:wcxStyleSnapshot(document.querySelector('main,#main,.site-main,.content-area')),header:wcxStyleSnapshot(document.querySelector('header,#masthead,.site-header'))} 412 }; 413 } 414 function captureDeepLayout(reason){ 415 var blob=buildDeepLayout(reason),a=wcxFindAnchor(),r=a.el.getBoundingClientRect(); 416 if(window.wegeneWCX&&wegeneWCX.diagnostics){ 417 logEvent('deep_layout',{viewportWidth:innerWidth,viewportHeight:innerHeight,screenWidth:screen.width,screenHeight:screen.height,visualViewportWidth:window.visualViewport?wcxRound(visualViewport.width):0,visualViewportHeight:window.visualViewport?wcxRound(visualViewport.height):0,visualViewportScale:window.visualViewport?wcxRound(visualViewport.scale):1,orientation:(screen.orientation&&screen.orientation.type)||'',scrollX:wcxRound(scrollX),scrollY:wcxRound(scrollY),anchorSelector:a.selector,anchorWidth:wcxRound(r.width),anchorLeft:wcxRound(r.left),anchorRight:wcxRound(r.right),debugMode:/[?&]wcx_debug=1/.test(location.search),diagnosticBlob:JSON.stringify(blob)}); 418 } 419 return blob; 420 } 421 function downloadDeepLayout(){ 422 var blob=captureDeepLayout('manual_download'); 423 var file=new Blob([JSON.stringify(blob,null,2)],{type:'application/json'}); 424 var url=URL.createObjectURL(file),a=document.createElement('a'); 425 a.href=url;a.download='wegene-mobile-layout-'+Date.now()+'.json';document.body.appendChild(a);a.click();a.remove();setTimeout(function(){URL.revokeObjectURL(url);},1000); 426 } 427 function copyDeepLayout(button){ 428 var text=JSON.stringify(captureDeepLayout('manual_copy'),null,2); 429 if(navigator.clipboard&&navigator.clipboard.writeText){navigator.clipboard.writeText(text).then(function(){button.textContent='Copied';}).catch(function(){button.textContent='Copy failed';});} 430 else{var ta=document.createElement('textarea');ta.value=text;document.body.appendChild(ta);ta.select();document.execCommand('copy');ta.remove();button.textContent='Copied';} 431 } 432})(jQuery); 433 434;(function($){ 435 function normalizePurchaseFlow(){ 436 if(!window.wegeneWCX||['cart','checkout'].indexOf(wegeneWCX.pageType)===-1)return; 437 var isCart=wegeneWCX.pageType==='cart'; 438 document.body.classList.add(isCart?'wcx-page-cart':'wcx-page-checkout'); 439 var anchor=document.querySelector(isCart?'.woocommerce-cart-form':'form.checkout')||document.querySelector('.woocommerce'); 440 if(!anchor)return; 441 var row=anchor.closest('.row'); 442 if(row){ 443 row.classList.add('wcx-flow-theme-row'); 444 var carrier=anchor; 445 while(carrier.parentElement&&carrier.parentElement!==row){carrier=carrier.parentElement;} 446 if(carrier&&carrier.parentElement===row){ 447 carrier.classList.add('wcx-flow-theme-column'); 448 Array.prototype.forEach.call(row.children,function(child){if(child!==carrier)child.classList.add('wcx-flow-theme-unused-column');}); 449 } 450 if(row.parentElement)row.parentElement.classList.add('wcx-flow-theme-container'); 451 var section=row.closest('section');if(section)section.classList.add('wcx-flow-theme-section'); 452 } 453 } 454 function normalizeCheckoutLayout(){ 455 if(!window.wegeneWCX||wegeneWCX.pageType!=='checkout')return; 456 var form=document.querySelector('form.checkout'); 457 var customer=document.querySelector('#customer_details'); 458 var heading=document.querySelector('#order_review_heading'); 459 var review=document.querySelector('#order_review'); 460 if(!form||!customer||!review)return; 461 462 /* v1.9.2: Keep WooCommerce checkout fragments in their native DOM order. 463 WooCommerce replaces #order_review during checkout updates; moving it 464 into a custom wrapper can leave an empty right column after refresh. */ 465 var layout=form.querySelector('.wcx-checkout-layout'); 466 if(layout){ 467 form.insertBefore(customer,layout); 468 if(heading)form.insertBefore(heading,layout); 469 form.insertBefore(review,layout); 470 layout.remove(); 471 } 472 customer.classList.add('wcx-checkout-customer-native'); 473 if(heading)heading.classList.add('wcx-checkout-order-heading-native'); 474 review.classList.add('wcx-checkout-order-native'); 475 476 document.querySelectorAll('#customer_details .form-row').forEach(function(row){ 477 row.style.removeProperty('width');row.style.removeProperty('max-width');row.style.removeProperty('float'); 478 }); 479 } 480 function enhanceNotices(){ 481 document.querySelectorAll('.woocommerce-notices-wrapper').forEach(function(wrapper){ 482 var notices=wrapper.querySelectorAll('.woocommerce-message,.woocommerce-info,.woocommerce-error'); 483 if(!notices.length)return; 484 if(wrapper.querySelector('.woocommerce-message'))wrapper.classList.add('wcx-toast-mode');
485 notices.forEach(function(notice){ 486 if(!notice.querySelector('.wcx-notice-text')){ 487 var text=document.createElement('span'); 488 text.className='wcx-notice-text'; 489 Array.from(notice.childNodes).forEach(function(node){ 490 if(node.nodeType===3 && node.textContent.trim()){ 491 text.appendChild(document.createTextNode(node.textContent.trim())); 492 node.remove(); 493 } 494 }); 495 if(text.textContent.trim()){ 496 var action=notice.querySelector('a.button,button.button'); 497 if(action)notice.insertBefore(text,action);else notice.appendChild(text); 498 } 499 } 500 if(!notice.querySelector('.wcx-notice-close')){ 501 var close=document.createElement('button');close.type='button';close.className='wcx-notice-close';close.setAttribute('aria-label','Dismiss notification');close.innerHTML='×';notice.appendChild(close); 502 } 503 }); 504 }); 505 } 506 $(document).on('click','.wcx-notice-close',function(){var n=this.closest('.woocommerce-message,.woocommerce-info,.woocommerce-error');if(n)n.remove();}); 507 $(document.body).on('added_to_cart updated_cart_totals updated_checkout',function(){setTimeout(function(){normalizeCheckoutLayout();enhanceNotices();},80);}); 508 normalizePurchaseFlow();normalizeCheckoutLayout();enhanceNotices(); 509 window.addEventListener('load',function(){normalizePurchaseFlow();normalizeCheckoutLayout();enhanceNotices();},{once:true}); 510})(jQuery); 511 512 513/* v1.12.0 mobile scroll/navigation diagnostics. Enabled with ?wcx_debug=1. */ 514;(function(){ 515 'use strict'; 516 var debug=/[?&]wcx_debug=1(?:&|$)/.test(location.search); 517 if(!debug)return; 518 var started=performance.now(), timeline=[], shifts=[], resources=[], maxEvents=240; 519 var lastScroll={x:scrollX,y:scrollY,t:0}; 520 function round(n){return Math.round((Number(n)||0)*100)/100;} 521 function elapsed(){return round(performance.now()-started);} 522 function selector(el){ 523 if(!el||el.nodeType!==1)return ''; 524 if(el.id)return '#'+el.id; 525 var out=(el.tagName||'').toLowerCase(); 526 if(el.classList&&el.classList.length)out+='.'+Array.prototype.slice.call(el.classList,0,4).join('.'); 527 return out; 528 } 529 function rect(el){ 530 if(!el||el.nodeType!==1)return null; 531 var r=el.getBoundingClientRect(),c=getComputedStyle(el); 532 return {selector:selector(el),x:round(r.x),y:round(r.y),width:round(r.width),height:round(r.height),top:round(r.top),bottom:round(r.bottom),display:c.display,position:c.position,overflowX:c.overflowX,overflowY:c.overflowY}; 533 } 534 function push(type,extra){ 535 timeline.push(Object.assign({t:elapsed(),type:type,scrollX:round(scrollX),scrollY:round(scrollY),docHeight:document.documentElement.scrollHeight,viewportH:innerHeight,hash:location.hash||'',active:selector(document.activeElement)},extra||{})); 536 if(timeline.length>maxEvents)timeline.shift(); 537 } 538 function navigationInfo(){ 539 var n=performance.getEntriesByType&&performance.getEntriesByType('navigation')[0]; 540 return n?{type:n.type,redirectCount:n.redirectCount,domInteractive:round(n.domInteractive),domContentLoaded:round(n.domContentLoadedEventEnd),loadEventEnd:round(n.loadEventEnd),transferSize:n.transferSize}:null; 541 } 542 function galleryInfo(){ 543 var g=document.querySelector('.woocommerce-product-gallery,.wcx-mobile-gallery'); 544 if(!g)return null; 545 return {gallery:rect(g),main:rect(g.querySelector('.wcx-mobile-gallery__main img,.woocommerce-product-gallery__image.flex-active-slide img,.woocommerce-product-gallery__image:first-child img')),thumbs:Array.prototype.slice.call(g.querySelectorAll('.flex-control-thumbs img,.wcx-mobile-gallery__thumb'),0,12).map(rect)}; 546 } 547 function buildReport(reason){ 548 var main=document.querySelector('main,#main,.site-main,.content-area'); 549 var product=document.querySelector('div.product,.wcx-product-layout'); 550 var header=document.querySelector('header,#masthead,.site-header'); 551 var notice=document.querySelector('.woocommerce-notices-wrapper,.woocommerce-message'); 552 return { 553 generatedAt:new Date().toISOString(),reason:reason||'manual',pluginVersion:(window.wegeneWCX&&wegeneWCX.pluginVersion)||'unknown', 554 href:location.href,referrer:document.referrer,userAgent:navigator.userAgent,language:navigator.language, 555 pageType:(window.wegeneWCX&&wegeneWCX.pageType)||'',navigation:navigationInfo(),historyScrollRestoration:history.scrollRestoration, 556 viewport:{innerWidth:innerWidth,innerHeight:innerHeight,scrollX:round(scrollX),scrollY:round(scrollY),clientWidth:document.documentElement.clientWidth,clientHeight:document.documentElement.clientHeight,scrollWidth:document.documentElement.scrollWidth,scrollHeight:document.documentElement.scrollHeight},
557 visualViewport:window.visualViewport?{width:round(visualViewport.width),height:round(visualViewport.height),scale:round(visualViewport.scale),offsetTop:round(visualViewport.offsetTop),pageTop:round(visualViewport.pageTop)}:null, 558 screen:{width:screen.width,height:screen.height,dpr:devicePixelRatio||1,orientation:(screen.orientation&&screen.orientation.type)||''}, 559 lifecycle:{readyState:document.readyState,visibility:document.visibilityState,persistedMarker:sessionStorage.getItem('wcxProductNavigation')||'',previousScroll:sessionStorage.getItem('wcxPreviousScroll')||''}, 560 elements:{header:rect(header),main:rect(main),product:rect(product),title:rect(document.querySelector('.product_title,h1')),gallery:galleryInfo(),summary:rect(document.querySelector('.summary,.wcx-product-summary')),notice:rect(notice),footer:rect(document.querySelector('footer'))}, 561 timeline:timeline.slice(),layoutShifts:shifts.slice(),recentResources:resources.slice(-40), 562 images:Array.prototype.slice.call(document.images,0,30).map(function(img){return {src:(img.currentSrc||img.src||'').split('?')[0],complete:img.complete,naturalWidth:img.naturalWidth,naturalHeight:img.naturalHeight,rect:rect(img)};}), 563 errors:(window.__wcxDebugErrors||[]).slice(-30) 564 }; 565 } 566 function download(){ 567 push('manual-download'); 568 var report=buildReport('manual_download'); 569 var file=new Blob([JSON.stringify(report,null,2)],{type:'application/json'}),url=URL.createObjectURL(file),a=document.createElement('a'); 570 a.href=url;a.download='wegene-mobile-scroll-debug-'+Date.now()+'.json';document.body.appendChild(a);a.click();a.remove();setTimeout(function(){URL.revokeObjectURL(url);},1500); 571 } 572 window.__wcxDebugErrors=[]; 573 window.addEventListener('error',function(e){window.__wcxDebugErrors.push({t:elapsed(),message:e.message,source:e.filename,line:e.lineno,column:e.colno});push('error',{message:e.message});}); 574 window.addEventListener('unhandledrejection',function(e){window.__wcxDebugErrors.push({t:elapsed(),message:String(e.reason||'unhandled rejection')});push('unhandledrejection',{message:String(e.reason||'')});}); 575 ['DOMContentLoaded','load','pageshow','pagehide','visibilitychange','hashchange','popstate','focus','blur','orientationchange','resize'].forEach(function(name){ 576 window.addEventListener(name,function(e){push(name,{persisted:!!e.persisted,visibility:document.visibilityState});},{passive:true}); 577 }); 578 window.addEventListener('scroll',function(){ 579 var now=performance.now();if(now-lastScroll.t<60)return; 580 push('scroll',{deltaX:round(scrollX-lastScroll.x),deltaY:round(scrollY-lastScroll.y)});lastScroll={x:scrollX,y:scrollY,t:now}; 581 },{passive:true}); 582 document.addEventListener('click',function(e){ 583 var a=e.target.closest&&e.target.closest('a');if(!a)return; 584 push('click',{target:selector(e.target),link:a.href||'',productLink:!!a.closest('li.product,.product')}); 585 if(a.closest('li.product')||/\/product\//.test(a.pathname||'')){ 586 sessionStorage.setItem('wcxProductNavigation',JSON.stringify({at:Date.now(),from:location.href,to:a.href,scrollY:scrollY})); 587 sessionStorage.setItem('wcxPreviousScroll',String(scrollY)); 588 } 589 },true); 590 document.addEventListener('load',function(e){if(e.target&&e.target.tagName==='IMG')push('image-load',{image:selector(e.target),src:(e.target.currentSrc||e.target.src||'').split('?')[0],naturalWidth:e.target.naturalWidth,naturalHeight:e.target.naturalHeight});},true); 591 if('PerformanceObserver'in window){ 592 try{new PerformanceObserver(function(list){list.getEntries().forEach(function(e){if(!e.hadRecentInput){shifts.push({t:elapsed(),value:round(e.value),sources:(e.sources||[]).map(function(s){return rect(s.node);})});if(shifts.length>80)shifts.shift();push('layout-shift',{value:round(e.value)});}});}).observe({type:'layout-shift',buffered:true});}catch(e){} 593 try{new PerformanceObserver(function(list){list.getEntries().forEach(function(e){if(e.initiatorType==='img'||e.initiatorType==='script'||e.initiatorType==='css')resources.push({name:(e.name||'').split('?')[0],type:e.initiatorType,start:round(e.startTime),duration:round(e.duration)});});}).observe({type:'resource',buffered:true});}catch(e){} 594 } 595 try{history.scrollRestoration='manual';}catch(e){} 596 push('debug-init',{navigation:navigationInfo(),referrer:document.referrer});
597 [0,50,150,350,700,1200,2000,3500].forEach(function(ms){setTimeout(function(){push('timed-snapshot',{delay:ms,main:rect(document.querySelector('main,#main,.site-main')),gallery:rect(document.querySelector('.woocommerce-product-gallery,.wcx-mobile-gallery'))});},ms);}); 598 function addPanel(){ 599 if(document.getElementById('wcx-mobile-debug-panel'))return; 600 var panel=document.createElement('aside');panel.id='wcx-mobile-debug-panel';panel.innerHTML='<strong>Wegene mobile debug</strong><span class="wcx-debug-readout"></span><div><button type="button" class="wcx-debug-download">Download JSON</button><button type="button" class="wcx-debug-top">Top</button><button type="button" class="wcx-debug-close" aria-label="Hide debug panel">Ã</button></div>'; 601 document.body.appendChild(panel); 602 function update(){var r=panel.querySelector('.wcx-debug-readout');if(r)r.textContent='Y '+Math.round(scrollY)+' | '+innerWidth+'Ã'+innerHeight+' | '+timeline.length+' events';} 603 panel.querySelector('.wcx-debug-download').addEventListener('click',download); 604 panel.querySelector('.wcx-debug-top').addEventListener('click',function(){push('manual-top-before');scrollTo(0,0);setTimeout(function(){push('manual-top-after');},100);}); 605 panel.querySelector('.wcx-debug-close').addEventListener('click',function(){panel.remove();}); 606 update();setInterval(update,500); 607 } 608 if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',addPanel);else addPanel(); 609 window.wcxDownloadMobileDebug=download; 610})(); 611 612/* v1.14.4 forensic product-navigation trace. Enabled with ?wcx_trace=1. 613 * Unlike the legacy debug tool, the API instrumentation begins in wp_head, 614 * before theme scripts. This footer layer persists the source-page trace, 615 * carries trace mode into product navigation, and exports a complete report. 616 */ 617;(function(){ 618 'use strict'; 619 if(!/[?&]wcx_trace=1(?:&|$)/.test(location.search))return; 620 var F=window.__wcxForensic||{events:[],add:function(){},cssPath:function(){return '';}}; 621 var sessionId=sessionStorage.getItem('wcxTraceSession')||('wcx-'+Date.now()+'-'+Math.random().toString(36).slice(2,8)); 622 sessionStorage.setItem('wcxTraceSession',sessionId); 623 function round(n){return Math.round((Number(n)||0)*100)/100;} 624 function path(el){return F.cssPath?F.cssPath(el):'';} 625 function rect(el){ 626 if(!el||el.nodeType!==1)return null; 627 var r=el.getBoundingClientRect(),c=getComputedStyle(el); 628 return {node:path(el),x:round(r.x),y:round(r.y),top:round(r.top),bottom:round(r.bottom),width:round(r.width),height:round(r.height),display:c.display,position:c.position,overflowAnchor:c.overflowAnchor,scrollMarginTop:c.scrollMarginTop,scrollSnapAlign:c.scrollSnapAlign,transform:c.transform}; 629 } 630 function nav(){var n=performance.getEntriesByType&&performance.getEntriesByType('navigation')[0];return n?{type:n.type,redirectCount:n.redirectCount,startTime:round(n.startTime),domInteractive:round(n.domInteractive),domContentLoaded:round(n.domContentLoadedEventEnd),loadEventEnd:round(n.loadEventEnd),transferSize:n.transferSize}:null;} 631 function keyElements(){ 632 var sels={header:'header.header-secondary.sticky-header,header.sticky-header,#masthead,.site-header',main:'#main,main.site-main,#primary',product:'div.product[id^="product-"],div.product',gallery:'.wcx-stable-gallery,.woocommerce-product-gallery',summary:'.summary.entry-summary,.wcx-product-summary',tabs:'.woocommerce-tabs,.wc-tabs-wrapper',related:'.related.products',footer:'footer'}; 633 var out={};Object.keys(sels).forEach(function(k){out[k]=rect(document.querySelector(sels[k]));});return out; 634 } 635 function anchors(){ 636 return Array.prototype.slice.call(document.querySelectorAll('a[href]'),0,250).map(function(a){ 637 var href=a.getAttribute('href')||''; 638 if(!/#|\/product\//.test(href))return null; 639 return {node:path(a),text:(a.textContent||'').trim().slice(0,120),rawHref:href,resolved:a.href||'',hash:(function(){try{return new URL(a.href,location.href).hash}catch(e){return ''}})(),rect:rect(a)}; 640 }).filter(Boolean); 641 } 642 function focusables(){ 643 return Array.prototype.slice.call(document.querySelectorAll('[autofocus],input,button,select,textarea,a[href]'),0,200).map(function(el){ 644 if(!el.hasAttribute('autofocus') && el!==document.activeElement)return null; 645 return {node:path(el),autofocus:el.hasAttribute('autofocus'),active:el===document.activeElement,rect:rect(el)}; 646 }
646).filter(Boolean); 647 } 648 function scripts(){return Array.prototype.slice.call(document.scripts).map(function(s){return s.src||('[inline] '+((s.id||s.textContent||'').slice(0,100)));}).slice(0,180);} 649 function styleState(){var de=getComputedStyle(document.documentElement),b=getComputedStyle(document.body);return {html:{scrollBehavior:de.scrollBehavior,overflowAnchor:de.overflowAnchor,scrollPaddingTop:de.scrollPaddingTop},body:{scrollBehavior:b.scrollBehavior,overflowAnchor:b.overflowAnchor,position:b.position,top:b.top}};} 650 function build(reason){ 651 var previous=null;try{previous=JSON.parse(sessionStorage.getItem('wcxTracePreviousPage')||'null');}catch(e){} 652 return {generatedAt:new Date().toISOString(),reason:reason||'manual',sessionId:sessionId,pluginVersion:(window.wegeneWCX&&wegeneWCX.pluginVersion)||'unknown',pageType:(window.wegeneWCX&&wegeneWCX.pageType)||'',href:location.href,hash:location.hash,referrer:document.referrer,userAgent:navigator.userAgent,navigation:nav(),history:{scrollRestoration:history.scrollRestoration,state:history.state,length:history.length},viewport:{innerWidth:innerWidth,innerHeight:innerHeight,scrollX:round(scrollX),scrollY:round(scrollY),docWidth:document.documentElement.scrollWidth,docHeight:document.documentElement.scrollHeight},visualViewport:window.visualViewport?{width:round(visualViewport.width),height:round(visualViewport.height),pageTop:round(visualViewport.pageTop),offsetTop:round(visualViewport.offsetTop),scale:round(visualViewport.scale)}:null,styles:styleState(),elements:keyElements(),target:rect(document.querySelector(':target')),activeElement:rect(document.activeElement),focusables:focusables(),anchors:anchors(),scripts:scripts(),earlyTrace:(F.events||[]).slice(),previousPage:previous,legacy:{productNavigation:sessionStorage.getItem('wcxProductNavigation')||'',previousScroll:sessionStorage.getItem('wcxPreviousScroll')||'',traceSourceHref:sessionStorage.getItem('wcxTraceSourceHref')||''}}; 653 } 654 function compactSource(){var r=build('source_before_navigation');delete r.previousPage;delete r.scripts;r.anchors=r.anchors.slice(0,80);r.earlyTrace=r.earlyTrace.slice(-500);return r;} 655 function persistSource(){try{sessionStorage.setItem('wcxTracePreviousPage',JSON.stringify(compactSource()));sessionStorage.setItem('wcxTraceSourceHref',location.href);}catch(e){}} 656 document.addEventListener('click',function(e){ 657 var a=e.target&&e.target.closest?e.target.closest('a[href]'):null;if(!a)return; 658 var u;try{u=new URL(a.href,location.href);}catch(err){return;} 659 if(u.origin!==location.origin||!/\/product\//.test(u.pathname))return; 660 persistSource(); 661 u.searchParams.set('wcx_trace','1'); 662 u.hash=''; 663 a.href=u.toString(); 664 if(F.add)F.add('trace-product-link-prepared',{href:a.href,raw:a.getAttribute('href')||'',sourceY:scrollY}); 665 },true); 666 window.addEventListener('pagehide',function(){persistSource();},{capture:true}); 667 668 function download(){ 669 if(F.add)F.add('trace-manual-download',{}); 670 var blob=new Blob([JSON.stringify(build('manual_download'),null,2)],{type:'application/json'}),url=URL.createObjectURL(blob),a=document.createElement('a'); 671 a.href=url;a.download='wegene-forensic-scroll-trace-'+Date.now()+'.json';document.body.appendChild(a);a.click();a.remove();setTimeout(function(){URL.revokeObjectURL(url);},1500); 672 } 673 function copyLink(){var u=new URL(location.href);u.searchParams.set('wcx_trace','1');u.hash='';navigator.clipboard&&navigator.clipboard.writeText(u.toString());} 674 function panel(){ 675 if(document.getElementById('wcx-forensic-panel'))return; 676 var el=document.createElement('aside');el.id='wcx-forensic-panel';el.style.cssText='position:fixed;z-index:2147483647;right:12px;bottom:12px;width:min(360px,calc(100vw - 24px));background:#10231f;color:white;padding:14px;border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.28);font:13px/1.35 system-ui,sans-serif'; 677 el.innerHTML='<div style="font-weight:800;font-size:14px;margin-bottom:5px">Wegene forensic trace</div><div class="wcx-trace-status" style="opacity:.8;margin-bottom:10px"></div><div style="display:flex;gap:7px;flex-wrap:wrap"><button type="button" data-a="download">Download full JSON</button><button type="button" data-a="copy">Copy trace link</button><button type="button" data-a="clear">Clear session</button><button type="button" data-a="close">Ã</button></div>'; 678 Array.prototype.forEach.call(el.querySelectorAll('button'),function(b){b.style.cssText='border:0;border-radius:9px;padding:8px 10px;font-weight:700;cursor:pointer';}); 679 document.body.appendChild(el); 680 el.querySelector('[data-a="download"]').onclick=download; 681 el.querySelector('[data-a="copy"]').onclick=copyLink; 682 el.querySelector('[data-a="clear"]').onclick=function(){sessionStorage.removeItem('wcxTracePreviousPage');sessionStorage.removeItem('wcxTraceSourceHref');sessionStorage.removeItem('wcxProductNavigation');sessionStorage.removeItem('wcxPreviousScroll');}; 683 el.querySelector('[data-a="close"]').onclick=function(){el.remove();};
684 function update(){var s=el.querySelector('.wcx-trace-status');if(s)s.textContent='Y '+Math.round(scrollY)+' · '+(F.events?F.events.length:0)+' early events · '+((window.wegeneWCX&&wegeneWCX.pageType)||'page');} 685 update();setInterval(update,400); 686 } 687 if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',panel,{once:true});else panel(); 688 window.wcxDownloadForensicTrace=download; 689})(); 690 691/* v1.15.8 â Final country/state control cleanup. 692 * WooCommerce/ThePlace can leave the native select or stale Select2 output visually present 693 * after checkout refreshes. Keep exactly one visible enhanced control and remove every 694 * duplicate selected-label artifact from the country/state wrappers. */ 695;(function($){ 696 'use strict'; 697 if(!$) return; 698 699 function optionLabels(select){ 700 if(!select) return []; 701 return Array.prototype.map.call(select.options || [], function(o){ 702 return String(o.textContent || o.innerText || '').trim(); 703 }).filter(Boolean); 704 } 705 706 function hideNative(select){ 707 if(!select) return; 708 select.classList.add('select2-hidden-accessible'); 709 select.setAttribute('aria-hidden','true'); 710 select.setAttribute('tabindex','-1'); 711 /* Do not leave the 1px accessibility box visible: ThePlace applies rules that can 712 leak the selected option text from that box. Select2 continues to read/write a 713 display:none select correctly. */ 714 select.style.setProperty('display','none','important'); 715 select.style.setProperty('visibility','hidden','important'); 716 select.style.setProperty('width','0','important'); 717 select.style.setProperty('height','0','important'); 718 select.style.setProperty('min-width','0','important'); 719 select.style.setProperty('min-height','0','important'); 720 select.style.setProperty('max-width','0','important'); 721 select.style.setProperty('max-height','0','important'); 722 select.style.setProperty('margin','0','important'); 723 select.style.setProperty('padding','0','important'); 724 select.style.setProperty('border','0','important'); 725 select.style.setProperty('font-size','0','important'); 726 select.style.setProperty('line-height','0','important'); 727 select.style.setProperty('opacity','0','important'); 728 select.style.setProperty('pointer-events','none','important'); 729 } 730 731 function cleanField(field){ 732 if(!field) return; 733 var wrap=field.querySelector('.woocommerce-input-wrapper'); 734 if(!wrap) return; 735 736 var native=wrap.querySelector('select.country_select, select.state_select, select.country_to_state, select.select2-hidden-accessible'); 737 var containers=Array.prototype.slice.call(wrap.querySelectorAll(':scope > .select2-container')); 738 if(!containers.length){
739 /* Select2 may not be initialized yet. Leave the native select usable until WooCommerce does so. */ 740 if(native){ 741 native.style.removeProperty('display'); 742 native.style.removeProperty('visibility'); 743 } 744 return; 745 } 746 747 hideNative(native); 748 749 /* WooCommerce can recreate Select2 after country/state changes. Keep only the newest container. */ 750 var active=containers[containers.length-1]; 751 containers.forEach(function(c){ 752 if(c!==active){ 753 c.style.setProperty('display','none','important'); 754 c.setAttribute('aria-hidden','true'); 755 } 756 }); 757 758 active.style.setProperty('display','block','important'); 759 active.style.setProperty('visibility','visible','important'); 760 active.style.setProperty('width','100%','important'); 761 active.style.setProperty('max-width','100%','important'); 762 active.style.setProperty('min-width','0','important'); 763 active.style.setProperty('margin','0','important'); 764 765 var selection=active.querySelector('.select2-selection--single'); 766 if(selection){ 767 selection.style.setProperty('width','100%','important'); 768 selection.style.setProperty('height','56px','important'); 769 selection.style.setProperty('min-height','56px','important'); 770 } 771 772 /* Remove theme-created orphan selected-value text nodes/spans beneath the control. */ 773 var labels=optionLabels(native); 774 Array.prototype.slice.call(wrap.childNodes).forEach(function(node){ 775 if(node===native || node===active) return; 776 var text=String(node.textContent || '').trim(); 777 if(!text) return; 778 if(labels.indexOf(text)!==-1){ 779 if(node.nodeType===3){ node.textContent=''; } 780 else if(node.nodeType===1){ 781 node.style.setProperty('display','none','important'); 782 node.setAttribute('aria-hidden','true'); 783 } 784 } 785 }); 786 } 787 788 function normalizeCheckoutCountryState(){ 789 var root=document.querySelector('body.wegene-wcx-active.wcx-page-checkout #customer_details'); 790 if(!root) return; 791 ['billing_country_field','billing_state_field','shipping_country_field','shipping_state_field'].forEach(function(id){ 792 cleanField(document.getElementById(id)); 793 }); 794 } 795 796 $(normalizeCheckoutCountryState); 797 $(document.body).on('updated_checkout country_to_state_changed init_checkout wc_fragments_refreshed', function(){ 798 window.requestAnimationFrame(normalizeCheckoutCountryState); 799 setTimeout(normalizeCheckoutCountryState,30); 800 setTimeout(normalizeCheckoutCountryState,180); 801 }); 802 new MutationObserver(function(mutations){ 803 var relevant=mutations.some(function(m){ 804 var el=m.target && (m.target.nodeType===1?m.target:m.target.parentElement); 805 return el && el.closest && el.closest('#billing_country_field,#billing_state_field,#shipping_country_field,#shipping_state_field'); 806 }); 807 if(relevant) window.requestAnimationFrame(normalizeCheckoutCountryState); 808 }).observe(document.documentElement,{subtree:true,childList:true,characterData:true}); 809})(window.jQuery); 810 811 812/* v1.15.9 â Hard-remove stray country/state display labels. 813 * ThePlace can emit selected-value text outside the native select/Select2 container. 814 * For these four fields, allow exactly one visible control and suppress every other 815 * direct visual child plus raw text nodes. */ 816;(function($){ 817 'use strict'; 818 if(!$) return; 819 var ids=['billing_country_field','billing_state_field','shipping_country_field','shipping_state_field']; 820 821 function hardClean(field){ 822 if(!field) return; 823 var wrap=field.querySelector('.woocommerce-input-wrapper'); 824 if(!wrap) return; 825 826 var containers=Array.prototype.slice.call(wrap.querySelectorAll('.select2-container')); 827 var active=null; 828 for(var i=containers.length-1;i>=0;i--){ 829 var c=containers[i]; 830 if(c && c.querySelector('.select2-selection--single')){ active=c; break; } 831 } 832 if(!active) return; 833 834 /* Raw text nodes are the source of the floating legacy value on this theme. */ 835 Array.prototype.slice.call(wrap.childNodes).forEach(function(node){ 836 if(node.nodeType===3){ node.nodeValue=''; } 837 }); 838 839 /* Keep only the active Select2 visual control. Everything else in this wrapper
840 is either the hidden native select or theme-generated duplicate UI. */ 841 Array.prototype.slice.call(wrap.children).forEach(function(child){ 842 if(child===active){ 843 child.style.setProperty('display','block','important'); 844 child.style.setProperty('visibility','visible','important'); 845 child.style.setProperty('width','100%','important'); 846 child.style.setProperty('font-size','16px','important'); 847 child.style.setProperty('line-height','normal','important'); 848 child.removeAttribute('aria-hidden'); 849 return; 850 } 851 if(child.tagName==='SELECT'){ 852 child.style.setProperty('display','none','important'); 853 child.style.setProperty('visibility','hidden','important'); 854 child.setAttribute('aria-hidden','true'); 855 child.setAttribute('tabindex','-1'); 856 return; 857 } 858 child.style.setProperty('display','none','important'); 859 child.style.setProperty('visibility','hidden','important'); 860 child.setAttribute('aria-hidden','true'); 861 }); 862 863 wrap.classList.add('wcx-select-clean'); 864 } 865 866 function run(){ ids.forEach(function(id){ hardClean(document.getElementById(id)); }); } 867 $(run); 868 $(document.body).on('updated_checkout country_to_state_changed init_checkout wc_fragments_refreshed',function(){ 869 requestAnimationFrame(run); setTimeout(run,40); setTimeout(run,200); 870 }); 871 new MutationObserver(function(){ requestAnimationFrame(run); }).observe(document.documentElement,{subtree:true,childList:true,characterData:true}); 872})(window.jQuery);
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.