Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare const className_productCard = "product-card__image-wrapper"; | ||
declare const attribute_previewImageUrl = "data-preview-image"; | ||
declare function load(): void; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare const className_productCard = "product-card__image-wrapper"; | ||
declare const attribute_previewImageUrl = "data-preview-image"; | ||
declare function load(): void; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,33 @@ | ||
// No Imports until webpack is setup | ||
|
||
console.log('Told Shopify-Script Injected'); | ||
const className_productCard = 'product-card__image-wrapper'; | ||
const attribute_previewImageUrl = 'data-preview-image'; | ||
|
||
function load() { | ||
console.log('shopify-script load START'); | ||
let elements = document.getElementsByClassName(className_productCard); | ||
let productCards: HTMLDivElement[] = Array.prototype.filter.call(elements, (x: HTMLDivElement) => { | ||
return x.getAttribute(attribute_previewImageUrl) != null; | ||
}); | ||
|
||
let products = productCards.map(x => ({ | ||
element: x, | ||
imageUrl: x.getAttribute(attribute_previewImageUrl) as string | ||
})); | ||
|
||
(window as any)['glip_add_image'] = () => { | ||
console.log('clicked glip_add_image'); | ||
}; | ||
|
||
products.forEach(x => { | ||
x.element.innerHTML = ` | ||
<img src='${x.imageUrl}' class='product-card__image'> | ||
<button click='javascript:glip_add_image()'>Add Your Image for a Preview</button> | ||
`; | ||
}); | ||
|
||
console.log('shopify-script load END'); | ||
} | ||
|
||
|
||
load(); |