Skip to content

Instantly share code, notes, and snippets.

@sprankhub
Last active December 14, 2016 07:00
Show Gist options
  • Save sprankhub/ff14363aa3a7103a92d5 to your computer and use it in GitHub Desktop.
Save sprankhub/ff14363aa3a7103a92d5 to your computer and use it in GitHub Desktop.
Responsive Trusted Shops Trustbadge
// make sure that $j is your jQuery function or customise accordingly
// make sure that "trustbadge" is the ID of your custom trusted shops container or customise accordingly
$j(window).on("load resize", function(e) {
// responsive Trusted Shops badge
var trustbadgeContainerWidth = $j('#trustbadge').width();
// trusted shops ignores the customBadgeWidth, so set the height accordingly
_tsConfig.customBadgeHeight = (90/264) * trustbadgeContainerWidth;
// on a normal load event, the badge is loaded afterwards anyway
if (e.type == 'resize' && typeof trustbadge == 'object' && typeof trustbadge.reInitialize == 'function') {
$j('#trustbadge').html('');
$j("[id^='tsbadge']").remove();
$j("[id^='tscard']").remove();
trustbadge.reInitialize();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment