Created
September 8, 2014 15:54
-
-
Save Webbist-dev/36ed4b7f35401367f331 to your computer and use it in GitHub Desktop.
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
// Add functionality for Ingredients "Card Flip" | |
// | |
$('.product-img-box-pdp').wrapInner('<div class="product-img-box-pdp-inner-wrap" style="display: none;" />'); | |
$(".ingredients-text").wrapInner('<div class="ingredients-text-inner-wrap"" />'); | |
$('.product-img-box-pdp').prepend('<div class="product-img-box-pdp-inner" style="width: 100%;" />'); | |
$('.product-img-box-pdp-inner').css('min-height', productImgHeight); | |
$('.product-img-box-pdp figure').clone().appendTo('.product-img-box-pdp-inner').show(); | |
$('.ingredients-button-close').click(function() { | |
$(".ingredients-link").removeClass('ingredient-active'); | |
$(".product-img-box-pdp-inner").flippy({ | |
content: $('.product-img-box-pdp-inner-wrap > figure'), | |
duration: 600, | |
direction: 'RIGHT' | |
}); | |
return false; | |
}); | |
// Desktop flippy | |
var bp_desktop = '1024px'; | |
$(".ingredients-link").click(function() { | |
$(".ingredients-link").removeClass('ingredient-active'); | |
var ingredientCode = $(this).data("ingredient"); | |
$(this).addClass('ingredient-active'); | |
$(".ingredients-text").each(function() { | |
if($(this).data("ingredient") == ingredientCode) { | |
// Only apply flippy.js at desktop | |
if (Modernizr.mq('only all and (min-width: ' + bp_desktop + ')')) { | |
$(".product-img-box-pdp-inner").flippy({ | |
content: $(this), | |
duration: 600, | |
direction: 'LEFT', | |
onFinish:function(){ | |
$('.ingredients-button-close').click(function() { | |
$(".ingredients-link").removeClass('ingredient-active'); | |
$(".product-img-box-pdp-inner").flippy({ | |
content: $('.product-img-box-pdp-inner-wrap > figure'), | |
duration: 600, | |
direction: 'RIGHT' | |
}); | |
return false; | |
}); | |
} | |
}); | |
} else { | |
// Hide elements on click | |
$('.product-img-box-pdp-inner-wrap')insertAfter('header'); | |
$('.product-img-box-pdp-inner-wrap').show('.ingredient-active'); | |
$('.main-container').hide(); | |
$('header .spacer-bottom-small').hide(); | |
$('.footer-container').hide(); | |
} | |
} | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment