Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<script type="text/javascript">
jQuery(document).bind('gform_post_render', function(e, formId, currentFormPage) {
var $form = jQuery('#gform_' + formId);
if ($'configurator-init') === true) {
$form.on('click', '.config-layer.image-choices-field .ginput_container_radio input', function (e) {
var $input = jQuery(this);
var $thisForm = $input.closest('form');
var $label = $'label');
var $choice = $label.closest('.image-choices-choice');
var $field = $choice.closest('.gfield');
var $previewArea = $thisForm.find('.gform_body li.preview-area');
var layerRef = $'layerRef');
var $layer = $previewArea.find('.'+layerRef);
var $img = $choice.find('span.image-choices-choice-image-wrap img:first').clone();
$img.attr('class', 'preview-item ' + $input.attr('id'));
$form.find('.gform_body .gfield.image-choices-field.config-layer').each(function(i, el){
var $field = jQuery(this);
if (!$field.find('.ginput_container_radio').length) {
return true;
var layerNum = i+1;
var layerRef = 'preview-layer-' + layerNum;
var fieldID = $field.attr('id');
var $previewArea = $field.closest('form').find('.gform_body li.preview-area');
$previewArea.append('<div class="preview-layer '+layerRef+' '+fieldID+'" style="z-index:'+layerNum+';"></div>');
$'layerRef', layerRef);
$'configurator-init', true);
jQuery('.gfield.image-choices-field.config-layer .ginput_container_radio input:checked').each(function(i, el){
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment