Created
August 19, 2019 14:18
-
-
Save akopcz2/c78f6e418edcbd21adc88eb562a1c04b to your computer and use it in GitHub Desktop.
Clone Child Shop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('resize', function(){ | |
let desktopThumbnailWrapper = document.querySelector('.thumbnails-wrapper'); | |
let desktopThumbnailParent = desktopThumbnailWrapper.parentNode; | |
let shopifyProductReviews = document.querySelector('#shopify-product-reviews'); | |
let shopifyReviewsProductParent = shopifyProductReviews.parentNode; | |
let shopifyProductReviewsClone = shopifyProductReviews.cloneNode(true); | |
let rightSide = document.querySelector('.grid__item.medium-up--one-half'); | |
//Desktop | |
if(window.innerWidth > 767){ | |
if(!rightSide.querySelector('#shopify-product-reviews')){ | |
console.log('NO REVIEWS') | |
desktopThumbnailWrapper.insertAdjacentElement('afterend', shopifyProductReviewsClone); | |
// Remove IE poly | |
shopifyProductReviews.parentNode.removeChild(shopifyProductReviews); | |
//mobile | |
} | |
console.log(shopifyReviewsProductParent.querySelector('#shopify-product-reviews')); | |
} else { | |
if(desktopThumbnailParent.querySelector('#shopify-product-reviews')){ | |
let productDesc = document.querySelector('.product-single__description'); | |
productDesc.insertAdjacentElement('afterend', shopifyProductReviewsClone); | |
//remove node from desktop thumbnail view | |
desktopThumbnailParent.querySelector('#shopify-product-reviews').remove(); | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment