1(function($){'use strict';const YayRevGallery={$modal:null,$gridModal:null,$mediaPanel:null,$reviewPanel:null,$counter:null,$thumbnails:null,mediaItems:[],currentIndex:0,isOpen:!1,isGridOpen:!1,touchStartX:0,touchEndX:0,touchStartY:0,touchEndY:0,contentExpanded:!1,init:function(){this.createModal();this.createGridModal();this.bindEvents()},createModal:function(){const modalHtml=` 2 <div id="yayrev-gallery-modal" class="yayrev-gallery" role="dialog" aria-modal="true" aria-label="Media Gallery"> 3 <div class="yayrev-gallery-overlay"></div> 4 5 <div class="yayrev-gallery-container"> 6 <!-- Left: Media Panel --> 7 <div class="yayrev-gallery-media-panel"> 8 <button type="button" class="yayrev-gallery-close" aria-label="Close gallery"> 9 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> 10 <line x1="18" y1="6" x2="6" y2="18"></line> 11 <line x1="6" y1="6" x2="18" y2="18"></line> 12 </svg> 13 </button> 14 15 <button type="button" class="yayrev-gallery-nav yayrev-gallery-prev" aria-label="Previous"> 16 <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> 17 <polyline points="15 18 9 12 15 6"></polyline> 18 </svg> 19 </button> 20 21 <button type="button" class="yayrev-gallery-nav yayrev-gallery-next" aria-label="Next"> 22 <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> 23 <polyline points="9 18 15 12 9 6"></polyline> 24 </svg> 25 </button> 26 27 <div class="yayrev-gallery-media-content"></div> 28 29 <div class="yayrev-gallery-media-footer"> 30 <div class="yayrev-gallery-counter"> 31 <span class="yayrev-gallery-current">1</span> 32 <span class="yayrev-gallery-separator">/</span> 33 <span class="yayrev-gallery-total">1</span> 34 </div> 35 <div class="yayrev-gallery-thumbnails"></div> 36 </div> 37 </div> 38 39 <!-- Right: Review Panel --> 40 <div class="yayrev-gallery-review-panel"> 41 <div class="yayrev-gallery-panel-handle" aria-hidden="true"> 42 <div class="yayrev-gallery-panel-handle-bar"></div> 43 </div> 44 <button type="button" class="yayrev-gallery-close yayrev-gallery-close-mobile" aria-label="Close gallery"> 45 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> 46 <line x1="18" y1="6" x2="6" y2="18"></line> 47 <line x1="6" y1="6" x2="18" y2="18"></line> 48 </svg> 49 </button> 50 51 <div class="yayrev-gallery-review-content"> 52 <div class="yayrev-gallery-review-header"> 53 <div class="yayrev-gallery-review-avatar-wrap"></div> 54 <div class="yayrev-gallery-review-meta"> 55 <span class="yayrev-gallery-review-author"></span> 56 <span class="yayrev-gallery-review-count"></span> 57 <span class="yayrev-gallery-review-date"></span> 58 </div> 59 </div> 60 61 <div class="yayrev-gallery-review-rating"></div> 62 63 <div class="yayrev-gallery-review-badges"></div> 64 65 <div class="yayrev-gallery-review-variation-attributes"></div> 66 67 <h4 class="yayrev-gallery-review-title"></h4> 68 <div class="yayrev-gallery-review-text"></div> 69 70 <div class="yayrev-gallery-review-reply" style="display: none;"> 71 <div class="yayrev-gallery-review-reply-header"> 72 <svg width="16" height="16" viewB
72ox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> 73 <path d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"/> 74 </svg> 75 <span class="yayrev-gallery-review-reply-author"></span> 76 <span class="yayrev-gallery-review-reply-date"></span> 77 </div> 78 <blockquote class="yayrev-gallery-review-reply-content"></blockquote> 79 </div> 80 </div> 81 82 <div class="yayrev-gallery-review-product" style="display: none;"> 83 <img class="yayrev-gallery-review-product__img" src="" alt="" /> 84 <span class="yayrev-gallery-review-product__name"></span> 85 <a class="yayrev-gallery-review-product__link" href="#">View product →</a> 86 </div> 87 </div> 88 </div> 89 </div> 90 `;$('body').append(modalHtml);this.$modal=$('#yayrev-gallery-modal');this.$mediaPanel=this.$modal.find('.yayrev-gallery-media-content');this.$reviewPanel=this.$modal.find('.yayrev-gallery-review-content');this.$counter=this.$modal.find('.yayrev-gallery-counter');this.$thumbnails=this.$modal.find('.yayrev-gallery-thumbnails')},createGridModal:function(){const gridModalHtml=` 91 <div id="yayrev-grid-modal" class="yayrev-grid-modal" role="dialog" aria-modal="true" aria-label="All Customer Photos & Videos"> 92 <div class="yayrev-grid-modal-overlay"></div> 93 <div class="yayrev-grid-modal-container"> 94 <div class="yayrev-grid-modal-header"> 95 <h3 class="yayrev-grid-modal-title">${yayrevGalleryI18n?.allMedia || 'Customer Photos & Videos'}</h3> 96 <button type="button" class="yayrev-grid-modal-close" aria-label="Close"> 97 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> 98 <line x1="18" y1="6" x2="6" y2="18"></line> 99 <line x1="6" y1="6" x2="18" y2="18"></line> 100 </svg> 101 </button> 102 </div> 103 <div class="yayrev-grid-modal-body"> 104 <div class="yayrev-grid-modal-grid"></div> 105 </div> 106 </div> 107 </div> 108 `;$('body').append(gridModalHtml);this.$gridModal=$('#yayrev-grid-modal')},bindEvents:function(){const self=this;$(document).on('click','.yayrev-media-thumb',function(e){e.preventDefault();const $thumb=$(this);const $container=$thumb.closest('.yayrev-review-media');const index=parseInt($thumb.data('index'),10);self.loadMediaFromContainer($container,'.yayrev-media-data');self.open(index)});$(document).on('click','.yayrev-media-grid__item, .yayrev-product-media-item',function(e){e.preventDefault();const $item=$(this);const $container=$item.closest('.yayrev-media-grid, .yayrev-product-media');const index=parseInt($item.data('index'),10);self.loadMediaFromContainer($container,'.yayrev-media-grid__data, .yayrev-product-media-data');self.open(index)});$(document).on('click','.yayrev-media-grid__view-all, .yayrev-media-grid__more, .yayrev-product-media-view-all, .yayrev-product-media-more',function(e){e.preventDefault();e.stopPropagation();let $container=$(this).closest('.yayrev-media-grid, .yayrev-product-media');if(!$container.length){$container=$(this).closest('.yayrev-store-media, .yayrev-product-media-section').find('.yayrev-media-grid, .yayrev-product-media')} 109self.loadMediaFromContainer($container,'.yayrev-media-grid__data, .yayrev-product-media-data');self.openGrid()});this.$gridModal.on('click','.yayrev-grid-modal-item',function(e){e.preventDefault();
109const index=parseInt($(this).data('index'),10);self.closeGrid();self.open(index)});this.$gridModal.on('click','.yayrev-grid-modal-close',function(){self.closeGrid()});this.$gridModal.on('click','.yayrev-grid-modal-overlay',function(){self.closeGrid()});this.$modal.on('click','.yayrev-gallery-close',function(){self.close()});this.$modal.on('click','.yayrev-gallery-overlay',function(){self.close()});this.$modal.on('click','.yayrev-gallery-prev',function(){self.prev()});this.$modal.on('click','.yayrev-gallery-next',function(){self.next()});this.$modal.on('click','.yayrev-gallery-thumb',function(){const index=parseInt($(this).data('index'),10);self.goTo(index)});$(document).on('keydown',function(e){if(self.isGridOpen&&e.key==='Escape'){self.closeGrid();return} 110if(!self.isOpen)return;switch(e.key){case 'Escape':self.close();break;case 'ArrowLeft':self.prev();break;case 'ArrowRight':self.next();break;case ' ':e.preventDefault();self.toggleVideo();break}});this.$modal.on('touchstart','.yayrev-gallery-media-panel',function(e){self.touchStartX=e.originalEvent.touches[0].clientX});this.$modal.on('touchend','.yayrev-gallery-media-panel',function(e){self.touchEndX=e.originalEvent.changedTouches[0].clientX;self.handleSwipe()});this.$modal.on('touchstart','.yayrev-gallery-review-panel',function(e){self.touchStartY=e.originalEvent.touches[0].clientY});this.$modal.on('touchend','.yayrev-gallery-review-panel',function(e){self.touchEndY=e.originalEvent.changedTouches[0].clientY;self.handleVerticalSwipe()});this.$modal.on('click','.yayrev-gallery-review-panel',function(e){if(!self.isMobile()||self.contentExpanded)return;if($(e.target).closest('.yayrev-gallery-close-mobile').length)return;self.expandContent()});this.$modal.on('click','.yayrev-gallery-media-panel',function(e){if(!self.isMobile()||!self.contentExpanded)return;if($(e.target).closest('.yayrev-gallery-nav, .yayrev-gallery-close').length)return;self.collapseContent()});this.$modal.on('click','.yayrev-gallery-panel-handle',function(e){if(!self.isMobile())return;e.stopPropagation();self.contentExpanded?self.collapseContent():self.expandContent()});this.$modal.on('wheel',function(e){if(!$(e.target).closest('.yayrev-gallery-review-panel').length){e.preventDefault()}})},loadMediaFromContainer:function($container,dataSelector){let $dataScript=$container.siblings(dataSelector);if(!$dataScript.length){const $card=$container.closest('.yayrev-media-grid, .yayrev-review-card, .yayrev-widget-review, .yayrev-store-review, .yayrev-store-media, [id^="li-comment-"]');if($card.length){$dataScript=$card.find(dataSelector)}} 111if($dataScript.length){try{this.mediaItems=JSON.parse($dataScript.text())}catch(e){console.error('YayReviews: Failed to parse media data');this.mediaItems=[]}}},open:function(index){if(this.mediaItems.length===0)return;this.currentIndex=index||0;this.isOpen=!0;this.buildThumbnails();this.showItem(this.currentIndex);this.updateCounter();this.resetMobileState();this.$modal.addClass('is-open');$('body').addClass('yayrev-gallery-open');this.$modal.find('.yayrev-gallery-close').first().focus()},close:function(){this.isOpen=!1;this.$modal.removeClass('is-open');$('body').removeClass('yayrev-gallery-open');this.$mediaPanel.find('video').each(function(){this.pause()});this.$mediaPanel.empty()},openGrid:function(){if(this.mediaItems.length===0)return;this.isGridOpen=!0;this.buildGrid();this.$gridModal.addClass('is-open');$('body').addClass('yayrev-grid-open')},closeGrid:function(){this.isGridOpen=!1;this.$gridModal.removeClass('is-open');$('body').removeClass('yayrev-grid-open')},buildGrid:function(){const self=this;const $grid=this.$gridModal.find('.yayrev-grid-modal-grid');$grid.empty();this.mediaItems.forEach((item,index)=>{const isVideo=item.type==='video';const thumbnail=item.thumbnail||this.getVideoPlaceholder();let itemHtml=` 112 <div class="yayrev-grid-modal-item" data-index="${index}" data-type="${item.type}" ${isVideo ? `data-video-url="${item.url}"` : ''}> 113 <img src="${thumbnail}" alt="" loading="lazy" /> 114 ${isVideo ? `<span class="yayrev-grid-modal-play"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><polygon points="5,3 19,12 5,21"/></svg></span>` : ''} 115 </div> 116 `;$grid.append(itemHtml)});if(window.YayRevVideoThumbnail){$grid.find('.yayrev-grid-modal-item[data-type="video"]').each(function(){const $item=$(this);const videoUrl=$item.data('video-url');if(videoUrl&&!$item.thumbnail){window.YayRevVideoThumbnail.extractThumbnail(videoUrl).then(dataUrl=>{$item.find('img').attr('src',dataUrl)}
116).catch(()=>{})}})}},prev:function(){if(this.currentIndex>0){this.goTo(this.currentIndex-1)}else{this.goTo(this.mediaItems.length-1)}},next:function(){if(this.currentIndex<this.mediaItems.length-1){this.goTo(this.currentIndex+1)}else{this.goTo(0)}},goTo:function(index){if(index<0||index>=this.mediaItems.length)return;this.$mediaPanel.find('video').each(function(){this.pause()});this.currentIndex=index;this.showItem(index);this.updateCounter();this.updateThumbnails()},showItem:function(index){const item=this.mediaItems[index];if(!item)return;this.$mediaPanel.empty();if(item.type==='video'){this.showVideo(item)}else{this.showImage(item)} 117this.showReviewInfo(item.review);this.updateNavigation()},showImage:function(item){const $wrapper=$('<div class="yayrev-gallery-image-wrapper"></div>');const $img=$('<img />').attr('src',item.full||item.url).attr('alt',item.alt||'').addClass('yayrev-gallery-image');$wrapper.addClass('is-loading');$img.on('load',function(){$wrapper.removeClass('is-loading')});$wrapper.append($img);this.$mediaPanel.append($wrapper)},showVideo:function(item){const $wrapper=$('<div class="yayrev-gallery-video-wrapper"></div>');const $video=$('<video controls playsinline></video>').attr('src',item.url).attr('poster',item.thumbnail).addClass('yayrev-gallery-video');$wrapper.append($video);this.$mediaPanel.append($wrapper);$video[0].play().catch(function(){})},showReviewInfo:function(review){if(!review){this.$reviewPanel.closest('.yayrev-gallery-review-panel').hide();return} 118this.$reviewPanel.closest('.yayrev-gallery-review-panel').show();const $avatarWrap=this.$reviewPanel.find('.yayrev-gallery-review-avatar-wrap');$avatarWrap.empty();if(review.avatar&&window.YayRevAvatarRender){$avatarWrap.html(window.YayRevAvatarRender.render(review.avatar,0,'yayrev-gallery-review-avatar'),)} 119this.$reviewPanel.find('.yayrev-gallery-review-author').text(review.author);const $reviewCount=this.$reviewPanel.find('.yayrev-gallery-review-count');if(review.reviewCount){$reviewCount.text(review.reviewCount).show()}else{$reviewCount.hide()} 120const $date=this.$reviewPanel.find('.yayrev-gallery-review-date');const showReviewDate=window.yayrevGallerySettings?.showReviewDate!==!1&&window.yayrevGallerySettings?.showReviewDate!=='';if(showReviewDate&&review.date){if(review.dateHtml){$date.html(review.dateHtml).show()}else{$date.text(review.date).show()}}else{$date.hide()} 121const $rating=this.$reviewPanel.find('.yayrev-gallery-review-rating');$rating.empty();if(window.YayRevRatingRender){$rating.html(window.YayRevRatingRender.render(review.rating,review.ratingType))} 122const $badges=this.$reviewPanel.find('.yayrev-gallery-review-badges');$badges.empty();const showVerifiedBadge=window.yayrevGallerySettings?.showVerifiedBadge;if(showVerifiedBadge&&review.verified){$badges.append(` 123 <span class="yayrev-verified-badge"> 124 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M13.6894 6.11822L12.7373 5.0125C12.5553 4.80255 12.4083 4.41065 12.4083 4.13072V2.94101C12.4083 2.1992 11.7992 1.59035 11.0572 1.59035H9.86711C9.5941 1.59035 9.19507 1.44339 8.98506 1.26143L7.87899 0.309673C7.39596 -0.103224 6.60491 -0.103224 6.11488 0.309673L5.01581 1.26843C4.8058 1.44339 4.40677 1.59035 4.13376 1.59035H2.92268C2.18064 1.59035 1.5716 2.1992 1.5716 2.94101V4.13772C1.5716 4.41065 1.42459 4.80255 1.24958 5.0125L0.304519 6.12522C-0.101506 6.6081 -0.101506 7.3919 0.304519 7.87478L1.24958 8.9875C1.42459 9.19745 1.5716 9.58935 1.5716 9.86228V11.059C1.5716 11.8008 2.18064 12.4096 2.92268 12.4096H4.13376C4.40677 12.4096 4.8058 12.5566 5.01581 12.7386L6.12188 13.6903C6.60491 14.1032 7.39596 14.1032 7.88599 13.6903L8.99206 12.7386C9.20207 12.5566 9.5941 12.4096 9.87411 12.4096H11.0642C11.8062 12.4096 12.4153 11.8008 12.4153 11.059V9.86928C12.4153 9.59635 12.5623 9.19745 12.7443 8.9875L13.6964 7.88178C14.1024 7.3989 14.1024 6.6011 13.6894 6.11822ZM9.90911 5.67733L6.5279 9.05748C6.4299 9.15546 6.29689 9.21145 6.15688 9.21145C6.01687 9.21145 5.88387 9.15546 5.78586 9.05748L4.09175 7.36391C3.88874 7.16096 3.88874 6.82504 4.09175 6.62209C4.29477 6.41915 4.63079 6.41915 4.8338 6.62209L6.15688 7.94476L9.16707 4.93552C9.37008 4.73257 9.7061 4.73257 9.90911 4.93552C10.1121 5.13847 10.1121 5.47438 9.90911 5.67733Z" fill="#088D59"/></svg>
125 <span>${yayrevGalleryI18n?.verified || 'Verified'}</span> 126 </span> 127 `)} 128if(review.badges&&Array.isArray(review.badges)&&review.badges.length>0){review.badges.forEach(badge=>{const icon=badge.icon?`<span class="yayrev-gallery-badge__icon">${badge.icon}</span>`:'';$badges.append(` 129 <span class="yayrev-gallery-badge" style="--badge-color: ${badge.color || '#6b7280'};" title="${badge.name}"> 130 ${icon} 131 <span class="yayrev-gallery-badge__label">${badge.name}</span> 132 </span> 133 `)})} 134const $variationAttributes=this.$reviewPanel.find('.yayrev-gallery-review-variation-attributes');if(review.variationAttributes){$variationAttributes.text(review.variationAttributes).show()}else{$variationAttributes.hide()} 135const $title=this.$reviewPanel.find('.yayrev-gallery-review-title');const showReviewTitle=window.yayrevGallerySettings?.showReviewTitle!==!1;if(showReviewTitle&&review.title){$title.text(review.title).show()}else{$title.hide()} 136this.$reviewPanel.find('.yayrev-gallery-review-text').html(review.content);const $reply=this.$reviewPanel.find('.yayrev-gallery-review-reply');if(review.reply){$reply.find('.yayrev-gallery-review-reply-author').text(review.reply.author);if(review.reply.dateHtml){$reply.find('.yayrev-gallery-review-reply-date').html(review.reply.dateHtml)}else{$reply.find('.yayrev-gallery-review-reply-date').text(review.reply.date)} 137$reply.find('.yayrev-gallery-review-reply-content').html(review.reply.content);$reply.show()}else{$reply.hide()} 138const $product=this.$reviewPanel.closest('.yayrev-gallery-review-panel').find('.yayrev-gallery-review-product');if(review.product&&review.product.url){$product.find('.yayrev-gallery-review-product__img').attr('src',review.product.image||'').attr('alt',review.product.name||'').toggle(!!review.product.image);$product.find('.yayrev-gallery-review-product__name').text(review.product.name||'');$product.find('.yayrev-gallery-review-product__link').attr('href',review.product.url);$product.show()}else{$product.hide()}},toggleVideo:function(){const $video=this.$mediaPanel.find('video');if($video.length){if($video[0].paused){$video[0].play()}else{$video[0].pause()}}},buildThumbnails:function(){const self=this;this.$thumbnails.empty();if(this.mediaItems.length<=1){this.$thumbnails.hide();return} 139this.$thumbnails.show();this.mediaItems.forEach(function(item,index){const $thumb=$('<button type="button" class="yayrev-gallery-thumb"></button>').attr('data-index',index).attr('aria-label','View item '+(index+1));const thumbnail=item.thumbnail||self.getVideoPlaceholder();if(item.type==='video'){$thumb.addClass('is-video');$thumb.attr('data-video-url',item.url);$thumb.html(` 140 <img src="${thumbnail}" alt="" /> 141 <span class="yayrev-gallery-thumb-play"> 142 <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"> 143 <polygon points="5,3 19,12 5,21"/> 144 </svg> 145 </span> 146 `);if(!item.thumbnail&&window.YayRevVideoThumbnail){window.YayRevVideoThumbnail.extractThumbnail(item.url).then(dataUrl=>{$thumb.find('img').attr('src',dataUrl)}).catch(()=>{})}}else{$thumb.html(`<img src="${item.thumbnail}" alt="" />`)} 147if(index===self.currentIndex){$thumb.addClass('is-active')} 148self.$thumbnails.append($thumb)})},getVideoPlaceholder:function(){return'data:image/svg+xml,'+encodeURIComponent(` 149 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100"> 150 <rect fill="#e5e7eb" width="100" height="100"/> 151 <polygon fill="#fff" points="40,30 40,70 70,50" opacity="0.8"/> 152 </svg> 153 `.trim())},updateThumbnails:function(){this.$thumbnails.find('.yayrev-gallery-thumb').removeClass('is-active').eq(this.currentIndex).addClass('is-active');const $active=this.$thumbnails.find('.is-active');if($active.length){$active[0].scrollIntoView({behavior:'smooth',block:'nearest',inline:'center'})}},updateCounter:function(){this.$counter.find('.yayrev-gallery-current').text(this.currentIndex+1);this.$counter.find('.yayrev-gallery-total').text(this.mediaItems.length)},updateNavigation:function(){const $prev=this.$modal.find('.yayrev-gallery-prev');const $next=this.$modal.find('.yayrev-gallery-next');
153if(this.mediaItems.length<=1){$prev.hide();$next.hide()}else{$prev.show();$next.show()}},isMobile:function(){return window.innerWidth<=480},resetMobileState:function(){this.contentExpanded=!1;this.$modal.find('.yayrev-gallery-container').removeClass('is-content-expanded')},expandContent:function(){this.contentExpanded=!0;this.$modal.find('.yayrev-gallery-container').addClass('is-content-expanded')},collapseContent:function(){this.contentExpanded=!1;this.$modal.find('.yayrev-gallery-container').removeClass('is-content-expanded')},handleVerticalSwipe:function(){if(!this.isMobile())return;const threshold=40;const diff=this.touchStartY-this.touchEndY;if(Math.abs(diff)<threshold)return;if(diff>0){this.expandContent()}else{this.collapseContent()}},handleSwipe:function(){const threshold=50;const diff=this.touchStartX-this.touchEndX;if(Math.abs(diff)<threshold)return;if(diff>0){this.next()}else{this.prev()}}};$(function(){YayRevGallery.init()});window.YayRevGallery=YayRevGallery})(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.