1window.JSVWoo = { 2 items: [], 3 errors: [] 4}; 5 6function createJsvWooInstance(generatedHtml, id, generatedHtmlLarge) { 7 const existing = window.JSVWoo.items.filter(instance => { 8 return instance.idInProductGallery === id; 9 }) 10 11 if (existing.length === 0) { 12 window.JSVWoo.items.push(new JsvWooProductGalleryInstance(generatedHtml, id, generatedHtmlLarge)); 13 } 14} 15 16class JsvWooProductGalleryInstance { 17 constructor(generatedHtml, id, generatedHtmlLarge) { 18 this.idInProductGallery = id; 19 this.generatedHtml = generatedHtml; 20 this.generatedHtmlLarge = generatedHtmlLarge; 21 22 this.jsvViewer = null; 23 this.jsvViewerPopup = null; 24 25 this.addIconAfterProductGallery(0); 26 this.setEventsForPhotoSwipe(0); 27 } 28 29 setEventsForPhotoSwipe(tries) { 30 if (document.getElementsByClassName('woocommerce-product-gallery__trigger').length === 0) { 31 setTimeout(() => { 32 if (tries < 10) { 33 this.setEventsForPhotoSwipe(tries++) 34 } 35 }, 100) 36 return 37 } 38 jQuery('.pswp__button--arrow--right,.pswp__button--arrow--right,.woocommerce-product-gallery__trigger') 39 .click(this._addPresentationInPhotoSwipe.bind(this)) 40 } 41 42 _getPhotoSwipeFrame() { 43 const div = document.createElement('div'); 44 div.style.margin = 'auto auto' 45 div.className = 'woo-photoswipe-holder' 46 return div; 47 } 48 49 _getPhotoSwipeMarginTop(photoSwipeWrapNode) { 50 const otherSwipeNode = this._getPhotoSwipeNode(2); 51 if(otherSwipeNode){ 52 return (otherSwipeNode.getBoundingClientRect().top - otherSwipeNode.offsetTop - otherSwipeNode.parentNode.offsetTop) /2; 53 } 54 55 return 0.1 * photoSwipeWrapNode.clientHeight; 56 } 57 58 _addPresentationInPhotoSwipe() { 59 setTimeout(() => { 60 const photoSwipeWrapNode = this._getPhotoSwipeNode(0) 61 if (photoSwipeWrapNode) { 62 63 const y = this._getPhotoSwipeMarginTop(photoSwipeWrapNode); 64 65 let div = this._getPhotoSwipeFrame(); 66 div.innerHTML = this.generatedHtmlLarge; 67 photoSwipeWrapNode.appendChild(div); 68 69 photoSwipeWrapNode.style.paddingTop = `${y}px` 70 71 for (let index = 0; index < photoSwipeWrapNode.childNodes.length; ++index) { 72 if (this.jsvViewerPopup) { 73 this.jsvViewerPopup.destroy(); 74 } 75 this.jsvViewerPopup = (new JsvInstance(photoSwipeWrapNode.childNodes[index].childNodes[0])); 76 jQuery('.woo-photoswipe-holder').on('pointerdown', (e) => { 77 e.stopPropagation() 78 }) 79 } 80 } 81 }, 1000) 82 } 83 84 _getPhotoSwipeNode(nChildNodes) { 85 const nodes = document.getElementsByClassName('pswp__zoom-wrap'); 86 for (let index = 0; index < nodes.length; ++index) { 87 if (nodes[index].childNodes.length === nChildNodes) { 88 return nodes[index]; 89 } 90 } 91 return null; 92 } 93 94 addIconAfterProductGallery(tries) { 95 if (!document.getElementById(this.idInProductGallery)) { 96 setTimeout(() => { 97 if (tries < 10) { 98 this.addIconAfterProductGallery(tries++) 99 } 100 }, 100) 101 return 102 } 103 104 const parent = document.getElementById(this.idInProductGallery); 105 parent.innerHTML = this.generatedHtml; 106 parent.className = '360-viewer-ignore'; 107 108 parent.addEventListener('touchstart', (e) => { 109 e.stopPropagation() 110 }) 111 for (let index = 0; index < parent.children.length; ++index) { 112 if (this.jsvViewer) { 113 this.jsvViewer.destroy(); 114 } 115 this.jsvViewer = (new JsvInstance(parent.children[index])); 116 } 117 } 118}
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.