Created
February 1, 2018 05:32
-
-
Save ogii/15a92fe14172effa6e9257e475da58ec to your computer and use it in GitHub Desktop.
Loading images into array + showing based on selection in VWO
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
vwo_$('a#severModalBTN, a#selectModalBTN').on('click', function(element) { | |
step2(vwo_$('#select-server input[type*="radio"]').filter(':checked').attr('value')); | |
}); | |
function step2(input) { | |
switch (input) { | |
case '27': | |
isSlimOrNot = true; | |
step3(vwo_$('div.normal').find(':checked').attr('value')); | |
break; | |
case '18': | |
isSlimOrNot = false; | |
step3(vwo_$('div.amadana2-color.select-form').find(':checked').attr('value')); | |
break; | |
case '14': | |
isSlimOrNot = false; | |
step3(vwo_$('div.amadana-color.select-form').find(':checked').attr('value')); | |
break; | |
case '29': | |
isSlimOrNot = false; | |
step3(vwo_$('div.cado-2017-color.select-form').find(':checked').attr('value')); | |
break; | |
} | |
} | |
function step3(value) { | |
if(isSlimOrNot) { | |
if(vwo_$('#longSize1').is(':checked')) { | |
vwo_$('div.modalContent img:nth-child(1)').attr('src', arrSlimLong[vwo_$('.width.server_color_slim3').find(':checked').attr('value')]["front"]); | |
vwo_$('div.modalContent img:nth-child(2)').attr('src', arrSlimLong[vwo_$('.width.server_color_slim3').find(':checked').attr('value')]["side"]); | |
} else if(vwo_$('#shortSize1').is(':checked')) { | |
console.log(vwo_$('width.server_color_slim3').find(':checked').attr('value')); | |
vwo_$('div.modalContent img:nth-child(1)').attr('src', arrSlimShort[vwo_$('.width.server_color_slim3').find(':checked').attr('value')]["front"]); | |
vwo_$('div.modalContent img:nth-child(2)').attr('src', arrSlimShort[vwo_$('.width.server_color_slim3').find(':checked').attr('value')]["side"]); | |
} | |
} else { | |
vwo_$('div.modalContent img:nth-child(1)').attr('src', arr[value]["front"]); | |
vwo_$('div.modalContent img:nth-child(2)').attr('src', arr[value]["side"]); | |
} | |
vwo_$('body, html').addClass('no-scroll'); | |
vwo_$('div#vwoModal').addClass('visible'); | |
} | |
})(jQuery); | |
var isSlimOrNot = false; | |
//put img src between quotes. The input values are on the left | |
var arr = { | |
"43": {"front": "", "side": ""} | |
}; | |
var arrSlimShort = { | |
"44": {"front": "", "side": ""} | |
}; | |
var arrSlimLong = { | |
"45": {"front": "", "side": ""} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment