Last active
November 15, 2023 23:07
-
-
Save CodeMonkeyG/dcbf1519710c21147b388161cffaa143 to your computer and use it in GitHub Desktop.
Gigya ShowScreenSet function cal for BeachBody
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
function resizeScreenSetFields(){ | |
$('.gigya-screen input').parents('.gigya-layout-cell').each(function(){ | |
if(parseInt($('.gigya-screen:visible').width()) == 375){ | |
$(this).css({ | |
'min-width' : (parseInt($('.gigya-screen:visible').width()) - 40) + 'px', | |
'width' : (parseInt($('.gigya-screen:visible').width()) - 40) + 'px' | |
}) | |
} else { | |
$(this).css({ | |
'min-width' : '', | |
'width' : '' | |
}) | |
} | |
}); | |
} | |
function showGigyaScreenSets(){ | |
var authFlow = 'popup'; | |
if(gigya.isMobile){ | |
authFlow = 'redirect'; | |
} | |
gigya.accounts.showScreenSet({ | |
screenSet : screenSet, | |
containerID : container, | |
startScreen : startScreen, | |
authFlow : authFlow, | |
onBeforeSubmit : function(event){ | |
$('.gigya-error-msg').text('').removeClass('gigya-error-msg-active'); | |
}, | |
onAfterSubmit : function(event){ | |
if(event.screen == 'gigya-update-profile-screen' && event.response.errorCode == 0){ | |
$('.gigya-success-msg').text('Your info has been updated successfully.'); | |
console.log('success'); | |
} | |
}, | |
onError : function(event){ | |
if(event.response.errorCode == 400003){ | |
startScreen = 'gigya-login-screen'; | |
showGigyaScreenSets(); | |
} | |
}, | |
onBeforeScreenLoad : function(event){ | |
if(event.nextScreen != 'gigya-login-screen' && event.nextScreen != 'gigya-register-screen'){ | |
$('#'+container).css({'max-width':'375px', 'margin' : '0 auto'}); | |
} | |
}, | |
onAfterScreenLoad : function(event){ | |
var compositeControls = $('.gigya-composite-control'); | |
$('.gigya-input-submit:visible').addClass('gigya-transparency'); | |
$.each(compositeControls, function(index, compositeControl){ | |
if($(compositeControl).find('.validation-indicator').length < 1){ | |
$(compositeControl).append('<span class="validation-indicator"></span>'); | |
} | |
}); | |
$('.gigya-screen .show-password').on('change', function(){ | |
if($(this).is(':checked')){ | |
$('[name="password"]:visible').attr('type', 'text'); | |
} else { | |
$('[name="password"]:visible').attr('type', 'password'); | |
} | |
}); | |
$('.gigya-social-login-container').height(function(){ | |
console.log($(this).find('[data-gigya-provider]:visible').length * 75); | |
var currentSocialLoginContainerHeight = $(this).height(); | |
var newSocialLoginContainerHeight = $(this).find('[data-gigya-provider]:visible').length * 75; | |
if(newSocialLoginContainerHeight >= currentSocialLoginContainerHeight){ | |
return newSocialLoginContainerHeight + 'px'; | |
} else { | |
return currentSocialLoginContainerHeight + 'px'; | |
} | |
}); | |
$(window).off('resize', resizeScreenSetFields); | |
resizeScreenSetFields(); | |
$(window).on('resize', resizeScreenSetFields); | |
}, | |
onFieldChanged : function(event){ | |
var field = $('#' + event.form + ' [name="' + event.field + '"]'); | |
var compositeControl = field.parents('.gigya-composite-control') ; | |
if(compositeControl.find('.validation-indicator').length < 1){ | |
compositeControl.append('<span class="validation-indicator"></span>'); | |
} | |
if(!event.isValid || compositeControl.find('input.gigya-error').length > 0){ | |
compositeControl.find('.validation-indicator').css('background-position', '30px 0px'); | |
field.removeClass('gigya-valid').addClass('gigya-error'); | |
} else { | |
compositeControl.find('.validation-indicator').css('background-position', '0px 0px'); | |
field.removeClass('gigya-error'); | |
} | |
if(($('input:visible').length - 1) == $('input.gigya-valid:visible').length){ | |
$('.gigya-input-submit:visible').removeClass('gigya-transparency'); | |
} | |
}, | |
onHide : function(event){ | |
} | |
}); | |
} | |
showGigyaScreenSets(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment