Example of Javascript for card component
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 ($) { | |
'use strict'; | |
Drupal.behaviors.card = { | |
attach: function (context, settings) { | |
var $bioButton = $('.card__view-bio', context); | |
var $bioDrawer = $('.card__bio', context); | |
var showBio = 'View full biography'; | |
var hideBio = 'Hide biography'; | |
$bioButton.on('click', function() { | |
$bioDrawer.toggleClass('is-open'); | |
$bioButton.toggleClass('flip-carat'); | |
if ($bioDrawer.hasClass('is-open')) { | |
$bioButton.text(hideBio); | |
$bioButton.toggleClass('is-open'); | |
} | |
else { | |
$bioButton.text(showBio); | |
$bioButton.removeClass('is-open'); | |
} | |
}); | |
} | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment