-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- JS changes to make products slideshow work awesome
- Loading branch information
Shawn King
committed
May 31, 2019
1 parent
b4dee36
commit bcae8f8
Showing
6 changed files
with
115 additions
and
94 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 |
---|---|---|
|
@@ -248,7 +248,7 @@ <h1 class="custom-page-header page-title has-dash">{{ page.name }}</h1> | |
<!--<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>--> | ||
<script src="//cdn.jsdelivr.net/gh/jquery/jquery@3/dist/jquery.min.js"></script> | ||
<!--<link href="https://cdn.jsdelivr.net/gh/sk5/[email protected]/assets/css/styles.css" rel="stylesheet" type="text/css" />--> | ||
<script src="//cdn.jsdelivr.net/gh/sk5/[email protected]/assets/scripts/product-slideshow.js"></script> | ||
<!--<script src="//cdn.jsdelivr.net/gh/sk5/[email protected]/assets/scripts/product-slideshow.js"></script>--> | ||
<!--<script> | ||
window.onload = function () { | ||
// Auto increment main images | ||
|
@@ -265,77 +265,86 @@ <h1 class="custom-page-header page-title has-dash">{{ page.name }}</h1> | |
}; | ||
//document.getElementsByClassName("product__thumbnail--link").click( | ||
//this.className += " active"; | ||
//alert("Clicked"); | ||
//this.className += " active"; | ||
//alert("Clicked"); | ||
//); | ||
//function changeProductImage() { | ||
//console.log("Hello"); | ||
////var slides = document.getElementsByClassName("product__slide"); | ||
//console.log(slides.length); | ||
////var currentButton = this.getAttribute("data-thumb"); | ||
////console.log(currentButton); | ||
////slides.forEach(function (el) { | ||
////el.classList.add("hidden") | ||
////}); | ||
// | ||
//console.log(slides.length); | ||
//---for (var i = 0; i < slides.length; i++) { | ||
//---var slide = slides[i]; | ||
//---slide.classList.remove("active"); | ||
//---} | ||
// | ||
// | ||
// New way??? | ||
var buttons = document.getElementsByClassName("product__thumbnail--link"); // target all buttons into a element array/collection | ||
var buttonsCount = buttons.length; // cache the length | ||
for (var h = 0; h < buttonsCount; h++) { // reset the counter; check if its smaller than the array length; add itself | ||
console.log("before button"); | ||
buttons[h].onclick = function (e) { // assign a function to the onclick event | ||
console.log("here"); | ||
var imageName = this.getAttribute("data-thumb"); // alert the id attribute of the element clicked | ||
//var element = document.querySelector("[data-slide='image-" + imageName "']"); | ||
var element = document.querySelector("[data-slide='image-" + imageName + "']"); | ||
console.log(element); | ||
// | ||
// | ||
var slides = document.getElementsByClassName("product__slide"); | ||
for (var i = 0; i < slides.length; i++) { | ||
var slide = slides[i]; | ||
slide.classList.remove("active"); | ||
} | ||
// | ||
element.classList.add("active"); | ||
}; | ||
} | ||
// | ||
// -- Old way that worked but not dynamically | ||
// -- var element = document.querySelector("[data-slide='image-1'"); | ||
// -- console.log(element.length); | ||
// -- element.classList.add("active"); | ||
//slides.classList.add("hidden"); | ||
//this.className += " active"; | ||
//console.log("Still here"); | ||
//} | ||
//console.log("Hello"); | ||
////var slides = document.getElementsByClassName("product__slide"); | ||
//console.log(slides.length); | ||
////var currentButton = this.getAttribute("data-thumb"); | ||
////console.log(currentButton); | ||
////slides.forEach(function (el) { | ||
////el.classList.add("hidden") | ||
////}); | ||
// | ||
//console.log(slides.length); | ||
//---for (var i = 0; i < slides.length; i++) { | ||
//---var slide = slides[i]; | ||
//---slide.classList.remove("active"); | ||
//---} | ||
// | ||
// | ||
// New way??? | ||
var buttons = document.getElementsByClassName("product__thumbnail--link"); // target all buttons into a element array/collection | ||
var buttonsCount = buttons.length; // cache the length | ||
for (var h = 0; h < buttonsCount; h++) { // reset the counter; check if its smaller than the array length; add itself | ||
//console.log("before button"); | ||
buttons[h].onclick = function (e) { // assign a function to the onclick event | ||
//console.log("here"); | ||
var imageName = this.getAttribute("data-thumb"); // alert the id attribute of the element clicked | ||
var currentButton = document.querySelector("[data-thumb='" + imageName + "']"); | ||
//var element = document.querySelector("[data-slide='image-" + imageName "']"); | ||
var element = document.querySelector("[data-slide='image-" + imageName + "']"); | ||
//console.log(element); | ||
console.log(currentButton); | ||
// | ||
var buttons = document.getElementsByClassName("product__thumbnail--link"); | ||
for (var j = 0; j < buttons.length; j++) { | ||
var button = buttons[j]; | ||
button.classList.remove("active"); | ||
} | ||
// | ||
currentButton.className += (" active"); | ||
// | ||
var slides = document.getElementsByClassName("product__slide"); | ||
for (var i = 0; i < slides.length; i++) { | ||
var slide = slides[i]; | ||
slide.classList.remove("active"); | ||
} | ||
// | ||
element.classList.add("active"); | ||
}; | ||
} | ||
// | ||
// -- Old way that worked but not dynamically | ||
// -- var element = document.querySelector("[data-slide='image-1'"); | ||
// -- console.log(element.length); | ||
// -- element.classList.add("active"); | ||
//slides.classList.add("hidden"); | ||
//this.className += " active"; | ||
//console.log("Still here"); | ||
//} | ||
//function show(nr) { | ||
//document.getElementById("table1").style.display = "none"; | ||
//document.getElementById("table2").style.display = "none"; | ||
//document.getElementById("table3").style.display = "none"; | ||
//document.getElementById("table4").style.display = "none"; | ||
//document.getElementById("table" + nr).style.display = "block"; | ||
// | ||
//var slides = document.getElementsByClassName("product__slide"); | ||
//slides.className += "hidden"; | ||
//slides.classList.add("hidden"); | ||
//-document.querySelectorAll("[data-slide='image'" + nr).className.remove("hidden"); | ||
// | ||
//-var thumbnails = document.getElementsByClassName("product__thumbnail--link"); | ||
//-thumbnails.className.remove("active"); | ||
//var currentSlide = slides.getAttribute('data-fruit'); | ||
//-this.className += "active"; | ||
//} | ||
//function show(nr) { | ||
//document.getElementById("table1").style.display = "none"; | ||
//document.getElementById("table2").style.display = "none"; | ||
//document.getElementById("table3").style.display = "none"; | ||
//document.getElementById("table4").style.display = "none"; | ||
//document.getElementById("table" + nr).style.display = "block"; | ||
// | ||
//var slides = document.getElementsByClassName("product__slide"); | ||
//slides.className += "hidden"; | ||
//slides.classList.add("hidden"); | ||
//-document.querySelectorAll("[data-slide='image'" + nr).className.remove("hidden"); | ||
// | ||
//-var thumbnails = document.getElementsByClassName("product__thumbnail--link"); | ||
//-thumbnails.className.remove("active"); | ||
//var currentSlide = slides.getAttribute('data-fruit'); | ||
//-this.className += "active"; | ||
//} | ||
</script>--> | ||
<script src="{{ 'api' | theme_js_url }}"></script> | ||
<script src="{{ theme | theme_js_url }}"></script> | ||
|
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
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
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
Large diffs are not rendered by default.
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