PageSourceSearch

https://ulumalazhar.com/wp-content/cache/min/1/wp-content/mu-plugi…/uaa-cart-toast.js?ver=1790286756

js ulumalazhar.com collected 2026-09-25 00:59:04 UTC 9,429 bytes, 59 lines download raw bytes

1(function(){'use strict';var CFG=window.uaaCartToast||{};var I18N=CFG.i18n||{};var LIFE=parseInt(CFG.life,10)>0?parseInt(CFG.life,10):6000;var CAP=LIFE+24000;var card=null,ui=null,dock=null;var liveCount=null;var hideT=null,killT=null,capT=null,coalesceT=null;var pending=null,shownAt=0;var startedAt=0,remaining=LIFE;function t(key,fallback){return I18N[key]||fallback}
2function fill(template,value){return String(template).replace('%s',value)}
3function readCart(fragments,productId){var html=fragments&&fragments['div.widget_shopping_cart_content'];if(!html){return null}
4var box=document.createElement('div');box.innerHTML=html;var items=box.querySelectorAll('.elementor-menu-cart__product, .woocommerce-mini-cart-item, li.mini_cart_item');var out={count:0,subtotal:'',line:null};var total=box.querySelector('.elementor-menu-cart__subtotal .amount, .woocommerce-mini-cart__total .amount, .total .amount');if(total){out.subtotal=(total.textContent||'').trim()}
5var mine=null;for(var i=0;i<items.length;i++){var n=qtyOf(items[i]);out.count+=n;if(!mine&&productId&&items[i].querySelector('[data-product_id="'+productId+'"]')){mine=items[i]}}
6if(!items.length){return out}
7if(!mine){mine=items[items.length-1]}
8var link=mine.querySelector('.product-name a, .elementor-menu-cart__product-name a');var title='';if(link){title=(link.textContent||'').trim()}else{var anchors=mine.querySelectorAll('a');for(var j=0;j<anchors.length;j++){var label=(anchors[j].textContent||'').trim();if(label.length>title.length){title=label}}}
9var img=mine.querySelector('img');out.line={title:title,img:img?(img.getAttribute('src')||''):'',qty:qtyOf(mine)};return out}
10function qtyOf(item){var node=item.querySelector('.product-quantity, .quantity');if(!node){return 1}
11var n=parseInt((node.textContent||'').replace(/[^0-9]+/g,' ').trim(),10);return n>0?n:1}
12var MINE='uaa_cart_count';function wcFragmentKey(){var p=window.wc_cart_fragments_params;if(p&&p.fragment_name){return p.fragment_name}
13try{for(var i=0;i<sessionStorage.length;i++){var k=sessionStorage.key(i);if(k&&k.indexOf('wc_fragments_')===0){return k}}}catch(e){}
14return null}
15function storedCount(){var key=wcFragmentKey();if(key){try{var raw=sessionStorage.getItem(key);if(raw){var state=readCart(JSON.parse(raw),'');return state?state.count:0}}catch(e){}}
16try{return parseInt(sessionStorage.getItem(MINE),10)||0}catch(e){return 0}}
17function rememberCount(count){try{sessionStorage.setItem(MINE,String(count))}catch(e){}}
18function fromPage(btn){var out={title:'',img:'',qty:0};if(!btn||!btn.closest){return out}
19var form=btn.closest('form.cart');if(form){var h=document.querySelector('.product_title');if(h){out.title=(h.textContent||'').trim()}
20out.img=imgSrc(document.querySelector('.woocommerce-product-gallery__image img, .elementor-widget-uicore-woo-product-gallery img'));var qtyField=form.querySelector('input[name="quantity"]');if(qtyField){out.qty=parseInt(qtyField.value,10)||0}
21return out}
22var cardEl=btn.closest('li.product, .bdt-wc-product, .elementor-loop-item, .product');if(cardEl){var name=cardEl.querySelector('.woocommerce-loop-product__title, .bdt-wc-product-title, h2, h3');if(name){out.title=(name.textContent||'').trim()}
23out.img=imgSrc(cardEl.querySelector('img'))}
24out.qty=parseInt(btn.getAttribute('data-quantity'),10)||0;return out}
25function imgSrc(img){if(!img){return''}
26var src=img.currentSrc||img.getAttribute('src')||'';if(src.indexOf('data:')===0){src=img.getAttribute('data-src')||img.getAttribute('data-lazy-src')||img.getAttribute('data-large_image')||''}
27return src}
28function buildCard(){var root=document.createElement('div');root.className='uaa-toast';root.setAttribute('role','status');root.setAttribute('aria-live','polite');root.setAttribute('aria-atomic','true');root.style.setProperty('--uaa-toast-life',LIFE+'ms');root.innerHTML='<div class="uaa-toast__progress"><i></i></div>'+'<div class="uaa-toast__body">'+'<img class="uaa-toast__thumb" alt="" decoding="async">'+'<div class="uaa-toast__text">'+'<p class="uaa-toast__eyebrow"></p>'+'<p class="uaa-toast__title"></p>'+'<p class="uaa-toast__meta"></p>'+'</div>'+'<button type="button" class="uaa-toast__close">
28'+'<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" focusable="false">'+'<path d="M3.5 3.5l9 9M12.5 3.5l-9 9" fill="none" stroke="currentColor" '+'stroke-width="1.6" stroke-linecap="round"/></svg>'+'</button>'+'</div>'+'<div class="uaa-toast__actions">'+'<a class="uaa-toast__btn uaa-toast__btn--ghost"><span></span></a>'+'<a class="uaa-toast__btn uaa-toast__btn--primary"><span></span></a>'+'</div>';ui={progress:root.querySelector('.uaa-toast__progress i'),thumb:root.querySelector('.uaa-toast__thumb'),eyebrow:root.querySelector('.uaa-toast__eyebrow'),title:root.querySelector('.uaa-toast__title'),meta:root.querySelector('.uaa-toast__meta'),close:root.querySelector('.uaa-toast__close'),ghost:root.querySelector('.uaa-toast__btn--ghost'),primary:root.querySelector('.uaa-toast__btn--primary')};ui.close.setAttribute('aria-label',t('close','Dismiss'));ui.close.addEventListener('click',dismiss);ui.ghost.href=CFG.cartUrl||'/cart/';ui.ghost.querySelector('span').textContent=t('viewCart','View cart');ui.primary.href=CFG.checkoutUrl||'/checkout/';ui.primary.querySelector('span').textContent=t('checkout','Checkout');root.addEventListener('mouseenter',hold);root.addEventListener('mouseleave',release);root.addEventListener('focusin',hold);root.addEventListener('focusout',release);return root}
29function showCard(line,subtotal){if(!card){card=buildCard();document.body.appendChild(card)}
30ui.eyebrow.textContent=t('added','Added to cart');ui.title.textContent=line.title||'';var bits=[];if(line.qty>0){bits.push(fill(t('qty','Qty %s'),line.qty))}
31if(subtotal){bits.push(fill(t('subtotal','Subtotal %s'),subtotal))}
32ui.meta.textContent=bits.join(' · ');if(line.img){ui.thumb.src=line.img;ui.thumb.alt=line.title||'';card.classList.remove('uaa-toast--nothumb')}else{ui.thumb.removeAttribute('src');card.classList.add('uaa-toast--nothumb')}
33if(dock){dock.style.display='none'}
34card.classList.remove('is-leaving');restart(card);restart(ui.progress);shownAt=Date.now();startTimer(LIFE);clearTimeout(capT);capT=setTimeout(dismiss,CAP)}
35function restart(node){var saved=node.style.animation;node.style.animation='none';void node.offsetWidth;node.style.animation=saved||''}
36function startTimer(ms){clearTimeout(hideT);startedAt=Date.now();remaining=ms;hideT=setTimeout(dismiss,ms)}
37function isHeld(){if(!card){return!1}
38try{if(card.matches(':hover')){return!0}}catch(e){}
39return!!(document.activeElement&&card.contains(document.activeElement))}
40function hold(){if(hideT===null){return}
41clearTimeout(hideT);hideT=null;remaining-=(Date.now()-startedAt);if(remaining<800){remaining=800}}
42function release(){setTimeout(function(){if(!card||hideT!==null||isHeld()){return}
43startTimer(remaining)},0)}
44function dismiss(){if(!card){return}
45clearTimeout(hideT);clearTimeout(capT);clearTimeout(killT);hideT=null;card.classList.add('is-leaving');var doomed=card;card=null;ui=null;killT=setTimeout(function(){if(doomed.parentNode){doomed.parentNode.removeChild(doomed)}
46syncDock()},240)}
47function buildDock(){var a=document.createElement('a');a.className='uaa-cartdock';a.href=CFG.cartUrl||'/cart/';a.innerHTML='<span class="uaa-cartdock__icon">'+'<svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true" focusable="false" '+'fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" '+'stroke-linejoin="round">'+'<path d="M2.5 3h2.1l2.4 11.4a1.7 1.7 0 0 0 1.7 1.35h8.4a1.7 1.7 0 0 0 1.7-1.35L21.5 7H5.6"/>'+'<circle cx="9.5" cy="20" r="1.3"/><circle cx="17.5" cy="20" r="1.3"/>'+'</svg>'+'</span>'+'<span class="uaa-cartdock__count"></span>';return a}
48function syncDock(){if(CFG.hideDock){return}
49var count=liveCount!==null?liveCount:storedCount();if(!count){if(dock&&dock.parentNode){dock.parentNode.removeChild(dock)}
50dock=null;return}
51if(!dock){dock=buildDock();document.body.appendChild(dock)}
52dock.style.display='';dock.querySelector('.uaa-cartdock__count').textContent=count>99?'99+':String(count);dock.setAttribute('aria-label',t('viewCart','View cart')+' ('+count+')')}
53function clearThemeBox(){var boxes=document.querySelectorAll('.uicore-added_to_cart');for(var i=0;i<boxes.length;i++){if(boxes[i].parentNode){boxes[i].parentNode.removeChild(boxes[i])}}}
54function handle(fragments,btn){if(!fragments&&!btn&&(Date.now()-shownAt)<1500){return}
55pending={fragments:fragments||(pending&&pending.fragments)||null,btn:btn||(pending&&pending.btn)||null};if(coalesceT){return}
56coalesceT=setTimeout(function(){var p=pending;pending=null;coalesceT=null;clearThemeBox();var id=p.btn?(p.btn.getAttribute('data-product_id')||p.btn.value||''):'';var state=readCart(p.fragments,id);var line=(state&&state.line)||fromPage(p.btn);if(state&&state.count){liveCount=state.count;rememberCount(state.count)}
57showCard(line,state?state.subtotal:'')},80)}
58if(window.jQuery){window.jQuery(document.body).on('added_to_cart',function(e,fragments,hash,$button){handle(fragments,($button&&$button[0])||null)});window.jQuery(document.body).on('removed_from_cart updated_wc_div wc_fragments_refreshed wc_fragments_loaded',function(){liveCount=null;if(!card){syncDock()}})}
59document.body.addEventListener('added_to_cart',function(){handle(null,null)});document.addEventListener('keydown',function(e){if(card&&(e.key==='Escape'||e.keyCode===27)){dismiss()}});syncDock()})()

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.