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 this.loadedInPhotoSwipe = false; 39 jQuery('.pswp__button--arrow--right,.pswp__button--arrow--right,.woocommerce-product-gallery__trigger') 40 .click(this._addPresentationInPhotoSwipe.bind(this)) 41 } 42 43 _getPhotoSwipeFrame() { 44 const div = document.createElement('div'); 45 div.style.margin = 'auto auto' 46 div.className = 'woo-photoswipe-holder' 47 return div; 48 } 49 50 _getPhotoSwipeMarginTop(photoSwipeWrapNode) { 51 const otherSwipeNode = this._getPhotoSwipeNode(2); 52 if(otherSwipeNode){ 53 return (otherSwipeNode.getBoundingClientRect().top - otherSwipeNode.offsetTop - otherSwipeNode.parentNode.offsetTop) /2; 54 } 55 56 return 0.1 * photoSwipeWrapNode.clientHeight; 57 } 58 59 _addPresentationInPhotoSwipe() { 60 setTimeout(() => { 61 const photoSwipeWrapNode = this._getPhotoSwipeNode(0) 62 if (photoSwipeWrapNode) { 63 64 const y = this._getPhotoSwipeMarginTop(photoSwipeWrapNode); 65 66 let div = this._getPhotoSwipeFrame(); 67 div.innerHTML = this.generatedHtmlLarge; 68 photoSwipeWrapNode.appendChild(div); 69 70 photoSwipeWrapNode.style.paddingTop = `${y}px` 71 72 for (let index = 0; index < photoSwipeWrapNode.childNodes.length; ++index) { 73 if (this.jsvViewerPopup) { 74 this.jsvViewerPopup.destroy(); 75 } 76 this.jsvViewerPopup = (new JsvInstance(photoSwipeWrapNode.childNodes[index].childNodes[0])); 77 this.loadedInPhotoSwipe = true; 78 jQuery('.woo-photoswipe-holder').on('pointerdown', (e) => { 79 e.stopPropagation() 80 }) 81 } 82 } 83 }, 1000) 84 } 85 86 _getPhotoSwipeNode(nChildNodes) { 87 const nodes = document.getElementsByClassName('pswp__zoom-wrap'); 88 for (let index = 0; index < nodes.length; ++index) { 89 if (nodes[index].childNodes.length === nChildNodes) { 90 return nodes[index]; 91 } 92 } 93 return null; 94 } 95 96 addIconAfterProductGallery(tries) { 97 if (!document.getElementById(this.idInProductGallery)) { 98 setTimeout(() => { 99 if (tries < 10) { 100 this.addIconAfterProductGallery(tries++) 101 } 102 }, 100) 103 return 104 } 105 106 const parent = document.getElementById(this.idInProductGallery); 107 parent.innerHTML = this.generatedHtml; 108 parent.className = '360-viewer-ignore' 109 parent.addEventListener('touchstart', (e) => { 110 e.stopPropagation() 111 }) 112 for (let index = 0; index < parent.childNodes.length; ++index) { 113 if (this.jsvViewer) { 114 this.jsvViewer.destroy(); 115 } 116 this.jsvViewer = (new JsvInstance(parent.childNodes[index])); 117 } 118 } 119}
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.